@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.
- package/LICENSE.md +840 -0
- package/README.md +38 -0
- package/dist/constants.d.ts +1 -0
- package/dist/constants.js +3 -0
- package/dist/constants.js.map +1 -0
- package/dist/main.d.ts +2 -0
- package/dist/main.js +4 -0
- package/dist/main.js.map +1 -0
- package/dist/program/Command.d.ts +42 -0
- package/dist/program/Command.js +64 -0
- package/dist/program/Command.js.map +1 -0
- package/dist/program/CommandAction.d.ts +12 -0
- package/dist/program/CommandAction.js +3 -0
- package/dist/program/CommandAction.js.map +1 -0
- package/dist/program/CommandArguments.d.ts +5 -0
- package/dist/program/CommandArguments.js +3 -0
- package/dist/program/CommandArguments.js.map +1 -0
- package/dist/program/CommandOptions.d.ts +11 -0
- package/dist/program/CommandOptions.js +3 -0
- package/dist/program/CommandOptions.js.map +1 -0
- package/dist/program/Program.d.ts +40 -0
- package/dist/program/Program.js +105 -0
- package/dist/program/Program.js.map +1 -0
- package/dist/program/ProgramDetail.d.ts +9 -0
- package/dist/program/ProgramDetail.js +5 -0
- package/dist/program/ProgramDetail.js.map +1 -0
- package/dist/program/ProgramError.d.ts +4 -0
- package/dist/program/ProgramError.js +8 -0
- package/dist/program/ProgramError.js.map +1 -0
- package/dist/program/ProgramOptions.d.ts +13 -0
- package/dist/program/ProgramOptions.js +5 -0
- package/dist/program/ProgramOptions.js.map +1 -0
- package/dist/program/ProgramStreams.d.ts +9 -0
- package/dist/program/ProgramStreams.js +5 -0
- package/dist/program/ProgramStreams.js.map +1 -0
- package/dist/program/getProgramDetail.d.ts +6 -0
- package/dist/program/getProgramDetail.js +27 -0
- package/dist/program/getProgramDetail.js.map +1 -0
- package/dist/program.d.ts +10 -0
- package/dist/program.js +12 -0
- package/dist/program.js.map +1 -0
- package/dist/ui/ErrorDetail.d.ts +12 -0
- package/dist/ui/ErrorDetail.js +5 -0
- package/dist/ui/ErrorDetail.js.map +1 -0
- package/dist/ui/Failure.d.ts +15 -0
- package/dist/ui/Failure.js +65 -0
- package/dist/ui/Failure.js.map +1 -0
- package/dist/ui/Header.d.ts +15 -0
- package/dist/ui/Header.js +26 -0
- package/dist/ui/Header.js.map +1 -0
- package/dist/ui/Help.d.ts +13 -0
- package/dist/ui/Help.js +64 -0
- package/dist/ui/Help.js.map +1 -0
- package/dist/ui/Spinner.d.ts +4 -0
- package/dist/ui/Spinner.js +39 -0
- package/dist/ui/Spinner.js.map +1 -0
- package/dist/ui/colors.d.ts +10 -0
- package/dist/ui/colors.js +12 -0
- package/dist/ui/colors.js.map +1 -0
- package/dist/ui/form/Form.d.ts +9 -0
- package/dist/ui/form/Form.js +3 -0
- package/dist/ui/form/Form.js.map +1 -0
- package/dist/ui/form/FormConfig.d.ts +8 -0
- package/dist/ui/form/FormConfig.js +3 -0
- package/dist/ui/form/FormConfig.js.map +1 -0
- package/dist/ui/form/FormProps.d.ts +40 -0
- package/dist/ui/form/FormProps.js +3 -0
- package/dist/ui/form/FormProps.js.map +1 -0
- package/dist/ui/form/FormResult.d.ts +6 -0
- package/dist/ui/form/FormResult.js +3 -0
- package/dist/ui/form/FormResult.js.map +1 -0
- package/dist/ui/form/FormRow.d.ts +30 -0
- package/dist/ui/form/FormRow.js +59 -0
- package/dist/ui/form/FormRow.js.map +1 -0
- package/dist/ui/form/FormRowConfig.d.ts +14 -0
- package/dist/ui/form/FormRowConfig.js +5 -0
- package/dist/ui/form/FormRowConfig.js.map +1 -0
- package/dist/ui/form/FormRowsConfig.d.ts +5 -0
- package/dist/ui/form/FormRowsConfig.js +3 -0
- package/dist/ui/form/FormRowsConfig.js.map +1 -0
- package/dist/ui/form/FormValue.d.ts +9 -0
- package/dist/ui/form/FormValue.js +3 -0
- package/dist/ui/form/FormValue.js.map +1 -0
- package/dist/ui/form/FormValues.d.ts +8 -0
- package/dist/ui/form/FormValues.js +3 -0
- package/dist/ui/form/FormValues.js.map +1 -0
- package/dist/ui/form/SelectInput.d.ts +29 -0
- package/dist/ui/form/SelectInput.js +123 -0
- package/dist/ui/form/SelectInput.js.map +1 -0
- package/dist/ui/form/SelectInputItem.d.ts +9 -0
- package/dist/ui/form/SelectInputItem.js +5 -0
- package/dist/ui/form/SelectInputItem.js.map +1 -0
- package/dist/ui/form/TextInput.d.ts +30 -0
- package/dist/ui/form/TextInput.js +155 -0
- package/dist/ui/form/TextInput.js.map +1 -0
- package/dist/ui/form/createForm.d.ts +9 -0
- package/dist/ui/form/createForm.js +72 -0
- package/dist/ui/form/createForm.js.map +1 -0
- package/dist/ui/form.d.ts +13 -0
- package/dist/ui/form.js +15 -0
- package/dist/ui/form.js.map +1 -0
- package/dist/ui/getErrorDetail.d.ts +5 -0
- package/dist/ui/getErrorDetail.js +63 -0
- package/dist/ui/getErrorDetail.js.map +1 -0
- package/dist/ui/icons.d.ts +9 -0
- package/dist/ui/icons.js +13 -0
- package/dist/ui/icons.js.map +1 -0
- package/dist/ui/internals/Wrapper.d.ts +12 -0
- package/dist/ui/internals/Wrapper.js +26 -0
- package/dist/ui/internals/Wrapper.js.map +1 -0
- package/dist/ui/internals/programContext.d.ts +9 -0
- package/dist/ui/internals/programContext.js +6 -0
- package/dist/ui/internals/programContext.js.map +1 -0
- package/dist/ui/internals/rotate.d.ts +8 -0
- package/dist/ui/internals/rotate.js +17 -0
- package/dist/ui/internals/rotate.js.map +1 -0
- package/dist/ui/internals.d.ts +3 -0
- package/dist/ui/internals.js +5 -0
- package/dist/ui/internals.js.map +1 -0
- package/dist/ui/useProgram.d.ts +7 -0
- package/dist/ui/useProgram.js +24 -0
- package/dist/ui/useProgram.js.map +1 -0
- package/dist/ui.d.ts +10 -0
- package/dist/ui.js +12 -0
- package/dist/ui.js.map +1 -0
- package/package.json +61 -0
- package/src/constants.ts +1 -0
- package/src/main.ts +2 -0
- package/src/program/Command.ts +121 -0
- package/src/program/CommandAction.ts +23 -0
- package/src/program/CommandArguments.ts +9 -0
- package/src/program/CommandOptions.ts +17 -0
- package/src/program/Program.ts +136 -0
- package/src/program/ProgramDetail.ts +9 -0
- package/src/program/ProgramError.ts +9 -0
- package/src/program/ProgramOptions.ts +16 -0
- package/src/program/ProgramStreams.ts +8 -0
- package/src/program/getProgramDetail.ts +38 -0
- package/src/program.ts +10 -0
- package/src/ui/ErrorDetail.ts +12 -0
- package/src/ui/Failure.tsx +59 -0
- package/src/ui/Header.tsx +37 -0
- package/src/ui/Help.tsx +68 -0
- package/src/ui/Spinner.tsx +30 -0
- package/src/ui/colors.ts +13 -0
- package/src/ui/form/Form.ts +9 -0
- package/src/ui/form/FormConfig.ts +9 -0
- package/src/ui/form/FormProps.ts +67 -0
- package/src/ui/form/FormResult.ts +8 -0
- package/src/ui/form/FormRow.tsx +119 -0
- package/src/ui/form/FormRowConfig.ts +17 -0
- package/src/ui/form/FormRowsConfig.ts +6 -0
- package/src/ui/form/FormValue.ts +12 -0
- package/src/ui/form/FormValues.ts +9 -0
- package/src/ui/form/SelectInput.tsx +165 -0
- package/src/ui/form/SelectInputItem.ts +10 -0
- package/src/ui/form/TextInput.tsx +228 -0
- package/src/ui/form/createForm.tsx +89 -0
- package/src/ui/form.ts +13 -0
- package/src/ui/getErrorDetail.ts +73 -0
- package/src/ui/icons.ts +13 -0
- package/src/ui/internals/Wrapper.tsx +34 -0
- package/src/ui/internals/programContext.ts +12 -0
- package/src/ui/internals/rotate.ts +12 -0
- package/src/ui/internals.ts +3 -0
- package/src/ui/useProgram.ts +24 -0
- package/src/ui.ts +10 -0
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Box, Text, useInput } from 'ink';
|
|
3
|
+
import _ from 'lodash';
|
|
4
|
+
import { useState, useEffect, useRef, useCallback } from 'react';
|
|
5
|
+
import * as colors from '../colors.js';
|
|
6
|
+
import * as icons from '../icons.js';
|
|
7
|
+
import { rotate } from '../internals.js';
|
|
8
|
+
/**
|
|
9
|
+
* Select input component.
|
|
10
|
+
*/ export function SelectInput({ label , items =[] , focus =true , initialIndex =0 , limit: customLimit , onSelect , onHighlight , marginTop =0 , isComplete , ...boxProps }) {
|
|
11
|
+
var _items_selectedIndex, _items_selectedIndex1;
|
|
12
|
+
let [rotateIndex, setRotateIndex] = useState(0);
|
|
13
|
+
let [selectedIndex, setSelectedIndex] = useState(initialIndex);
|
|
14
|
+
let hasLimit = typeof customLimit === 'number' && items.length > customLimit;
|
|
15
|
+
let limit = hasLimit ? Math.min(customLimit, items.length) : items.length;
|
|
16
|
+
let previousItems = useRef(items);
|
|
17
|
+
useEffect(()=>{
|
|
18
|
+
if (!_.isEqual(previousItems.current.map((item)=>item.value), items.map((item)=>item.value))) {
|
|
19
|
+
setRotateIndex(0);
|
|
20
|
+
setSelectedIndex(0);
|
|
21
|
+
}
|
|
22
|
+
previousItems.current = items;
|
|
23
|
+
}, [
|
|
24
|
+
items
|
|
25
|
+
]);
|
|
26
|
+
let inputHandler = useCallback((input, key)=>{
|
|
27
|
+
if (input === 'k' || key.upArrow) {
|
|
28
|
+
let lastIndex = (hasLimit ? limit : items.length) - 1;
|
|
29
|
+
let atFirstIndex = selectedIndex === 0;
|
|
30
|
+
let nextIndex = hasLimit ? selectedIndex : lastIndex;
|
|
31
|
+
let nextRotateIndex = atFirstIndex ? rotateIndex + 1 : rotateIndex;
|
|
32
|
+
let nextSelectedIndex = atFirstIndex ? nextIndex : selectedIndex - 1;
|
|
33
|
+
setRotateIndex(nextRotateIndex);
|
|
34
|
+
setSelectedIndex(nextSelectedIndex);
|
|
35
|
+
let slicedItems = hasLimit ? rotate(items, nextRotateIndex).slice(0, limit) : items;
|
|
36
|
+
if (typeof onHighlight === 'function') {
|
|
37
|
+
onHighlight(slicedItems[nextSelectedIndex]);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
if (input === 'j' || key.downArrow) {
|
|
41
|
+
let isAtLastIndex = selectedIndex === (hasLimit ? limit : items.length) - 1;
|
|
42
|
+
let nextIndex = hasLimit ? selectedIndex : 0;
|
|
43
|
+
let nextRotateIndex = isAtLastIndex ? rotateIndex - 1 : rotateIndex;
|
|
44
|
+
let nextSelectedIndex = isAtLastIndex ? nextIndex : selectedIndex + 1;
|
|
45
|
+
setRotateIndex(nextRotateIndex);
|
|
46
|
+
setSelectedIndex(nextSelectedIndex);
|
|
47
|
+
let slicedItems = hasLimit ? rotate(items, nextRotateIndex).slice(0, limit) : items;
|
|
48
|
+
if (typeof onHighlight === 'function') {
|
|
49
|
+
onHighlight(slicedItems[nextSelectedIndex]);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
if (key.return) {
|
|
53
|
+
let slicedItems = hasLimit ? rotate(items, rotateIndex).slice(0, limit) : items;
|
|
54
|
+
if (typeof onSelect === 'function') {
|
|
55
|
+
onSelect(slicedItems[selectedIndex]);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}, [
|
|
59
|
+
hasLimit,
|
|
60
|
+
limit,
|
|
61
|
+
rotateIndex,
|
|
62
|
+
selectedIndex,
|
|
63
|
+
items,
|
|
64
|
+
onSelect,
|
|
65
|
+
onHighlight
|
|
66
|
+
]);
|
|
67
|
+
useInput(inputHandler, {
|
|
68
|
+
isActive: focus
|
|
69
|
+
});
|
|
70
|
+
let visibleItem = hasLimit ? rotate(items, rotateIndex).slice(0, limit) : items;
|
|
71
|
+
return /*#__PURE__*/ _jsxs(Box, {
|
|
72
|
+
...boxProps,
|
|
73
|
+
children: [
|
|
74
|
+
/*#__PURE__*/ _jsx(Box, {
|
|
75
|
+
marginRight: 1,
|
|
76
|
+
children: /*#__PURE__*/ _jsx(Text, {
|
|
77
|
+
children: isComplete ? icons.success : icons.question
|
|
78
|
+
})
|
|
79
|
+
}),
|
|
80
|
+
/*#__PURE__*/ _jsxs(Box, {
|
|
81
|
+
flexDirection: "column",
|
|
82
|
+
children: [
|
|
83
|
+
/*#__PURE__*/ _jsx(Box, {
|
|
84
|
+
marginRight: 1,
|
|
85
|
+
children: /*#__PURE__*/ _jsx(Text, {
|
|
86
|
+
color: colors.highlighted,
|
|
87
|
+
children: label
|
|
88
|
+
})
|
|
89
|
+
}),
|
|
90
|
+
isComplete ? /*#__PURE__*/ _jsx(Text, {
|
|
91
|
+
color: colors.body,
|
|
92
|
+
children: ((_items_selectedIndex = items[selectedIndex]) === null || _items_selectedIndex === void 0 ? void 0 : _items_selectedIndex.label) ?? String((_items_selectedIndex1 = items[selectedIndex]) === null || _items_selectedIndex1 === void 0 ? void 0 : _items_selectedIndex1.value)
|
|
93
|
+
}) : /*#__PURE__*/ _jsx(Box, {
|
|
94
|
+
flexDirection: "column",
|
|
95
|
+
children: visibleItem.map((item, index)=>{
|
|
96
|
+
let isSelected = index === selectedIndex;
|
|
97
|
+
return /*#__PURE__*/ _jsxs(Box, {
|
|
98
|
+
children: [
|
|
99
|
+
/*#__PURE__*/ _jsx(Box, {
|
|
100
|
+
marginRight: 1,
|
|
101
|
+
children: isSelected ? /*#__PURE__*/ _jsx(Text, {
|
|
102
|
+
color: colors.selected,
|
|
103
|
+
children: icons.selectedCircle
|
|
104
|
+
}) : /*#__PURE__*/ _jsx(Text, {
|
|
105
|
+
color: colors.unselected,
|
|
106
|
+
children: icons.unselectedCircle
|
|
107
|
+
})
|
|
108
|
+
}),
|
|
109
|
+
/*#__PURE__*/ _jsx(Text, {
|
|
110
|
+
color: isSelected ? colors.highlighted : colors.muted,
|
|
111
|
+
children: `${item.label}`
|
|
112
|
+
})
|
|
113
|
+
]
|
|
114
|
+
}, item.value);
|
|
115
|
+
})
|
|
116
|
+
})
|
|
117
|
+
]
|
|
118
|
+
})
|
|
119
|
+
]
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
//# sourceMappingURL=SelectInput.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/ui/form/SelectInput.tsx"],"sourcesContent":["import {Box, type BoxProps, Text, useInput, type Key} from 'ink';\nimport _ from 'lodash';\nimport {useState, useEffect, useRef, useCallback} from 'react';\n\nimport {type SelectInputItem} from './SelectInputItem.js';\nimport * as colors from '../colors.js';\nimport * as icons from '../icons.js';\nimport {rotate} from '../internals.js';\n\n/**\n * Select input component props.\n */\ntype SelectInputProps = BoxProps & {\n /** Text to display as a label. */\n label: string;\n\n /** Items to display in a list. */\n items: SelectInputItem[];\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 | undefined;\n\n /** Index of initially selected item. */\n initialIndex?: number | undefined;\n\n /** Number of items to display. */\n limit?: number | undefined;\n\n /** Handler function that is called when item is selected. */\n onSelect?: ((item: SelectInputItem) => void) | undefined;\n\n /** Handler function that is called when item is highlighted. */\n onHighlight?: ((item: SelectInputItem) => void) | undefined;\n\n /** Indicates whether value has been accepted. Component then doesn't accept more input. */\n isComplete?: boolean | undefined;\n};\n\n/**\n * Select input component.\n */\nexport function SelectInput({\n label,\n items = [],\n focus = true,\n initialIndex = 0,\n limit: customLimit,\n onSelect,\n onHighlight,\n marginTop = 0,\n isComplete,\n ...boxProps\n}: SelectInputProps): JSX.Element {\n let [rotateIndex, setRotateIndex] = useState(0);\n let [selectedIndex, setSelectedIndex] = useState(initialIndex);\n let hasLimit = typeof customLimit === 'number' && items.length > customLimit;\n let limit = hasLimit ? Math.min(customLimit as number, items.length) : items.length;\n let previousItems = useRef<SelectInputItem[]>(items);\n\n useEffect(() => {\n if (\n !_.isEqual(\n previousItems.current.map((item) => item.value),\n items.map((item) => item.value),\n )\n ) {\n setRotateIndex(0);\n setSelectedIndex(0);\n }\n\n previousItems.current = items;\n }, [items]);\n\n let inputHandler = useCallback(\n (input: string, key: Key) => {\n if (input === 'k' || key.upArrow) {\n let lastIndex = (hasLimit ? limit : items.length) - 1;\n let atFirstIndex = selectedIndex === 0;\n let nextIndex = hasLimit ? selectedIndex : lastIndex;\n let nextRotateIndex = atFirstIndex ? rotateIndex + 1 : rotateIndex;\n let nextSelectedIndex = atFirstIndex ? nextIndex : selectedIndex - 1;\n\n setRotateIndex(nextRotateIndex);\n setSelectedIndex(nextSelectedIndex);\n\n let slicedItems = hasLimit ? rotate(items, nextRotateIndex).slice(0, limit) : items;\n\n if (typeof onHighlight === 'function') {\n onHighlight(slicedItems[nextSelectedIndex] as SelectInputItem);\n }\n }\n\n if (input === 'j' || key.downArrow) {\n let isAtLastIndex = selectedIndex === (hasLimit ? limit : items.length) - 1;\n let nextIndex = hasLimit ? selectedIndex : 0;\n let nextRotateIndex = isAtLastIndex ? rotateIndex - 1 : rotateIndex;\n let nextSelectedIndex = isAtLastIndex ? nextIndex : selectedIndex + 1;\n\n setRotateIndex(nextRotateIndex);\n setSelectedIndex(nextSelectedIndex);\n\n let slicedItems = hasLimit ? rotate(items, nextRotateIndex).slice(0, limit) : items;\n\n if (typeof onHighlight === 'function') {\n onHighlight(slicedItems[nextSelectedIndex] as SelectInputItem);\n }\n }\n\n if (key.return) {\n let slicedItems = hasLimit ? rotate(items, rotateIndex).slice(0, limit) : items;\n\n if (typeof onSelect === 'function') {\n onSelect(slicedItems[selectedIndex] as SelectInputItem);\n }\n }\n },\n [hasLimit, limit, rotateIndex, selectedIndex, items, onSelect, onHighlight],\n );\n\n useInput(inputHandler, {isActive: focus});\n\n let visibleItem: SelectInputItem[] = hasLimit\n ? rotate(items, rotateIndex).slice(0, limit)\n : items;\n\n return (\n <Box {...boxProps}>\n <Box marginRight={1}>\n <Text>{isComplete ? icons.success : icons.question}</Text>\n </Box>\n\n <Box flexDirection=\"column\">\n <Box marginRight={1}>\n <Text color={colors.highlighted}>{label}</Text>\n </Box>\n {isComplete ? (\n <Text color={colors.body}>\n {items[selectedIndex]?.label ?? String(items[selectedIndex]?.value)}\n </Text>\n ) : (\n <Box flexDirection=\"column\">\n {visibleItem.map((item, index) => {\n let isSelected = index === selectedIndex;\n\n return (\n <Box key={item.value}>\n <Box marginRight={1}>\n {isSelected ? (\n <Text color={colors.selected}>{icons.selectedCircle}</Text>\n ) : (\n <Text color={colors.unselected}>{icons.unselectedCircle}</Text>\n )}\n </Box>\n <Text\n color={isSelected ? colors.highlighted : colors.muted}\n >{`${item.label}`}</Text>\n </Box>\n );\n })}\n </Box>\n )}\n </Box>\n </Box>\n );\n}\n"],"names":["Box","Text","useInput","_","useState","useEffect","useRef","useCallback","colors","icons","rotate","SelectInput","label","items","focus","initialIndex","limit","customLimit","onSelect","onHighlight","marginTop","isComplete","boxProps","rotateIndex","setRotateIndex","selectedIndex","setSelectedIndex","hasLimit","length","Math","min","previousItems","isEqual","current","map","item","value","inputHandler","input","key","upArrow","lastIndex","atFirstIndex","nextIndex","nextRotateIndex","nextSelectedIndex","slicedItems","slice","downArrow","isAtLastIndex","return","isActive","visibleItem","marginRight","success","question","flexDirection","color","highlighted","body","String","index","isSelected","selected","selectedCircle","unselected","unselectedCircle","muted"],"mappings":";AAAA,SAAQA,GAAG,EAAiBC,IAAI,EAAEC,QAAQ,QAAiB,MAAM;AACjE,OAAOC,OAAO,SAAS;AACvB,SAAQC,QAAQ,EAAEC,SAAS,EAAEC,MAAM,EAAEC,WAAW,QAAO,QAAQ;AAG/D,YAAYC,YAAY,eAAe;AACvC,YAAYC,WAAW,cAAc;AACrC,SAAQC,MAAM,QAAO,kBAAkB;AA+BvC;;CAEC,GACD,OAAO,SAASC,YAAY,EAC1BC,MAAK,EACLC,OAAQ,EAAE,CAAA,EACVC,OAAQ,KAAI,EACZC,cAAe,EAAC,EAChBC,OAAOC,YAAW,EAClBC,SAAQ,EACRC,YAAW,EACXC,WAAY,EAAC,EACbC,WAAU,EACV,GAAGC,UACc;QAqFNT,sBAAsCA;IApFjD,IAAI,CAACU,aAAaC,eAAe,GAAGpB,SAAS;IAC7C,IAAI,CAACqB,eAAeC,iBAAiB,GAAGtB,SAASW;IACjD,IAAIY,WAAW,OAAOV,gBAAgB,YAAYJ,MAAMe,SAASX;IACjE,IAAID,QAAQW,WAAWE,KAAKC,IAAIb,aAAuBJ,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M,CAAC;;;+BAVTuB,KAAKC;wBAanB;;;;;;AAMZ"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/ui/form/SelectInputItem.ts"],"sourcesContent":["/**\n * Select input item.\n */\nexport type SelectInputItem = {\n /** Text to display as a label. */\n label: string;\n\n /** Value. */\n value: string;\n};\n"],"names":[],"mappings":"AAAA;;CAEC,GACD,WAME"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { type BoxProps } from 'ink';
|
|
2
|
+
/**
|
|
3
|
+
* Text input component props.
|
|
4
|
+
*/
|
|
5
|
+
export type TextInputProps = BoxProps & {
|
|
6
|
+
/** Text to display as a label. */
|
|
7
|
+
label: string;
|
|
8
|
+
/** Text to display when `value` is empty. */
|
|
9
|
+
placeholder?: string | undefined;
|
|
10
|
+
/** Value. */
|
|
11
|
+
value: string;
|
|
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
|
+
/** Replace all chars and mask the value. Useful for password inputs. */
|
|
15
|
+
mask?: string | undefined;
|
|
16
|
+
/** Show cursor and allow navigation using arrow keys. */
|
|
17
|
+
showCursor?: boolean | undefined;
|
|
18
|
+
/** Validation function that is called when value changes. If this function throws an error*/
|
|
19
|
+
validate?: ((value: string) => void) | undefined;
|
|
20
|
+
/** Handler function that is called when value changes. */
|
|
21
|
+
onChange: (value: string) => void;
|
|
22
|
+
/** Handler function that is called when enter is pressed. */
|
|
23
|
+
onSubmit?: ((value: string) => void) | undefined;
|
|
24
|
+
/** Indicates whether value has been accepted. Component then doesn't accept more input. */
|
|
25
|
+
isComplete?: boolean | undefined;
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* Text input component.
|
|
29
|
+
*/
|
|
30
|
+
export declare function TextInput({ label, validate, isComplete, value: originalValue, placeholder, focus, mask, showCursor, onChange, onSubmit, ...boxProps }: TextInputProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
// TODO: resolve
|
|
2
|
+
/* eslint-disable complexity -- TODO */ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import chalk from 'chalk';
|
|
4
|
+
import { Box, Text, useInput } from 'ink';
|
|
5
|
+
import { useEffect, useState } from 'react';
|
|
6
|
+
import * as colors from '../colors.js';
|
|
7
|
+
import * as icons from '../icons.js';
|
|
8
|
+
/**
|
|
9
|
+
* Text input component.
|
|
10
|
+
*/ export function TextInput({ label , validate , isComplete , value: originalValue , placeholder ='' , focus =true , mask , showCursor =true , onChange , onSubmit , ...boxProps }) {
|
|
11
|
+
let [validationError, setValidationError] = useState('');
|
|
12
|
+
let [state, setState] = useState({
|
|
13
|
+
cursorOffset: (originalValue || '').length,
|
|
14
|
+
cursorWidth: 0
|
|
15
|
+
});
|
|
16
|
+
useEffect(()=>{
|
|
17
|
+
setState((previousState)=>{
|
|
18
|
+
if (!focus || !showCursor) {
|
|
19
|
+
return previousState;
|
|
20
|
+
}
|
|
21
|
+
let newValue = originalValue || '';
|
|
22
|
+
if (previousState.cursorOffset > newValue.length - 1) {
|
|
23
|
+
return {
|
|
24
|
+
cursorOffset: newValue.length,
|
|
25
|
+
cursorWidth: 0
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
return previousState;
|
|
29
|
+
});
|
|
30
|
+
}, [
|
|
31
|
+
originalValue,
|
|
32
|
+
focus,
|
|
33
|
+
showCursor
|
|
34
|
+
]);
|
|
35
|
+
let value = mask ? mask.repeat(originalValue.length) : originalValue;
|
|
36
|
+
let renderedValue = value;
|
|
37
|
+
let renderedPlaceholder = placeholder ? chalk[colors.muted](placeholder) : undefined;
|
|
38
|
+
// fake mouse cursor; dealing with with actual cursor and ANSI escape codes is inconvinient
|
|
39
|
+
if (showCursor && focus) {
|
|
40
|
+
renderedPlaceholder = placeholder.length > 0 ? chalk.inverse(placeholder[0]) + chalk[colors.muted](placeholder.slice(1)) : chalk.inverse(' ');
|
|
41
|
+
renderedValue = value.length > 0 ? '' : chalk.inverse(' ');
|
|
42
|
+
let i = 0;
|
|
43
|
+
for (let char of value){
|
|
44
|
+
if (i >= state.cursorOffset && i <= state.cursorOffset) {
|
|
45
|
+
renderedValue += chalk.inverse(char);
|
|
46
|
+
} else {
|
|
47
|
+
renderedValue += char;
|
|
48
|
+
}
|
|
49
|
+
i += 1;
|
|
50
|
+
}
|
|
51
|
+
if (value.length > 0 && state.cursorOffset === value.length) {
|
|
52
|
+
renderedValue += chalk.inverse(' ');
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
useInput((input, key)=>{
|
|
56
|
+
if (key.upArrow || key.downArrow || key.ctrl && input === 'c' || key.shift && key.tab || key.tab) {
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
if (key.return) {
|
|
60
|
+
if (onSubmit) {
|
|
61
|
+
if (validate) {
|
|
62
|
+
try {
|
|
63
|
+
validate(originalValue);
|
|
64
|
+
} catch (error) {
|
|
65
|
+
setValidationError(error.message);
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
if (validationError) {
|
|
70
|
+
setValidationError('');
|
|
71
|
+
} else {
|
|
72
|
+
onSubmit(originalValue);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
let nextCursorOffset = state.cursorOffset;
|
|
78
|
+
let nextValue = originalValue;
|
|
79
|
+
let nextCursorWidth = 0;
|
|
80
|
+
if (key.leftArrow) {
|
|
81
|
+
if (showCursor) {
|
|
82
|
+
nextCursorOffset -= 1;
|
|
83
|
+
}
|
|
84
|
+
} else if (key.rightArrow) {
|
|
85
|
+
if (showCursor) {
|
|
86
|
+
nextCursorOffset += 1;
|
|
87
|
+
}
|
|
88
|
+
} else if (key.backspace || key.delete) {
|
|
89
|
+
if (state.cursorOffset > 0) {
|
|
90
|
+
nextValue = originalValue.slice(0, state.cursorOffset - 1) + originalValue.slice(state.cursorOffset, originalValue.length);
|
|
91
|
+
nextCursorOffset -= 1;
|
|
92
|
+
}
|
|
93
|
+
} else {
|
|
94
|
+
nextValue = originalValue.slice(0, state.cursorOffset) + input + originalValue.slice(state.cursorOffset, originalValue.length);
|
|
95
|
+
nextCursorOffset += input.length;
|
|
96
|
+
if (input.length > 1) {
|
|
97
|
+
nextCursorWidth = input.length;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
if (state.cursorOffset < 0) {
|
|
101
|
+
nextCursorOffset = 0;
|
|
102
|
+
}
|
|
103
|
+
if (state.cursorOffset > originalValue.length) {
|
|
104
|
+
nextCursorOffset = originalValue.length;
|
|
105
|
+
}
|
|
106
|
+
setState({
|
|
107
|
+
cursorOffset: nextCursorOffset,
|
|
108
|
+
cursorWidth: nextCursorWidth
|
|
109
|
+
});
|
|
110
|
+
if (nextValue !== originalValue) {
|
|
111
|
+
onChange(nextValue);
|
|
112
|
+
}
|
|
113
|
+
}, {
|
|
114
|
+
isActive: focus
|
|
115
|
+
});
|
|
116
|
+
return /*#__PURE__*/ _jsxs(Box, {
|
|
117
|
+
...boxProps,
|
|
118
|
+
children: [
|
|
119
|
+
/*#__PURE__*/ _jsx(Box, {
|
|
120
|
+
marginRight: 1,
|
|
121
|
+
children: /*#__PURE__*/ _jsx(Text, {
|
|
122
|
+
children: isComplete ? icons.success : icons.question
|
|
123
|
+
})
|
|
124
|
+
}),
|
|
125
|
+
/*#__PURE__*/ _jsxs(Box, {
|
|
126
|
+
flexDirection: "column",
|
|
127
|
+
children: [
|
|
128
|
+
/*#__PURE__*/ _jsx(Box, {
|
|
129
|
+
marginRight: 1,
|
|
130
|
+
children: /*#__PURE__*/ _jsx(Text, {
|
|
131
|
+
color: colors.highlighted,
|
|
132
|
+
children: label
|
|
133
|
+
})
|
|
134
|
+
}),
|
|
135
|
+
isComplete ? /*#__PURE__*/ _jsx(Text, {
|
|
136
|
+
color: colors.body,
|
|
137
|
+
children: value
|
|
138
|
+
}) : /*#__PURE__*/ _jsx(Text, {
|
|
139
|
+
color: colors.highlighted,
|
|
140
|
+
children: placeholder ? value.length > 0 ? renderedValue : renderedPlaceholder : renderedValue
|
|
141
|
+
}),
|
|
142
|
+
validationError ? /*#__PURE__*/ _jsx(Box, {
|
|
143
|
+
marginTop: 0,
|
|
144
|
+
children: /*#__PURE__*/ _jsx(Text, {
|
|
145
|
+
color: colors.warning,
|
|
146
|
+
children: validationError
|
|
147
|
+
})
|
|
148
|
+
}) : null
|
|
149
|
+
]
|
|
150
|
+
})
|
|
151
|
+
]
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
//# sourceMappingURL=TextInput.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/ui/form/TextInput.tsx"],"sourcesContent":["// TODO: resolve\n/* eslint-disable complexity -- TODO */\nimport chalk from 'chalk';\nimport {Box, type BoxProps, Text, useInput} from 'ink';\nimport {useEffect, useState} from 'react';\n\nimport * as colors from '../colors.js';\nimport * as icons from '../icons.js';\n\n/**\n * Text input component props.\n */\nexport type TextInputProps = BoxProps & {\n /** Text to display as a label. */\n label: string;\n\n /** Text to display when `value` is empty. */\n placeholder?: string | undefined;\n\n /** Value. */\n value: string;\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 | undefined;\n\n /** Replace all chars and mask the value. Useful for password inputs. */\n mask?: string | undefined;\n\n /** Show cursor and allow navigation using arrow keys. */\n showCursor?: boolean | undefined;\n\n /** Validation function that is called when value changes. If this function throws an error*/\n validate?: ((value: string) => void) | undefined;\n\n /** Handler function that is called when value changes. */\n onChange: (value: string) => void;\n\n /** Handler function that is called when enter is pressed. */\n onSubmit?: ((value: string) => void) | undefined;\n\n /** Indicates whether value has been accepted. Component then doesn't accept more input. */\n isComplete?: boolean | undefined;\n};\n\n/**\n * Text input component.\n */\nexport function TextInput({\n label,\n validate,\n isComplete,\n value: originalValue,\n placeholder = '',\n focus = true,\n mask,\n showCursor = true,\n onChange,\n onSubmit,\n ...boxProps\n}: TextInputProps) {\n let [validationError, setValidationError] = useState('');\n let [state, setState] = useState({\n cursorOffset: (originalValue || '').length,\n cursorWidth: 0,\n });\n\n useEffect(() => {\n setState((previousState) => {\n if (!focus || !showCursor) {\n return previousState;\n }\n\n let newValue = originalValue || '';\n\n if (previousState.cursorOffset > newValue.length - 1) {\n return {\n cursorOffset: newValue.length,\n cursorWidth: 0,\n };\n }\n\n return previousState;\n });\n }, [originalValue, focus, showCursor]);\n\n let value = mask ? mask.repeat(originalValue.length) : originalValue;\n let renderedValue = value;\n let renderedPlaceholder = placeholder ? chalk[colors.muted](placeholder) : undefined;\n\n // fake mouse cursor; dealing with with actual cursor and ANSI escape codes is inconvinient\n if (showCursor && focus) {\n renderedPlaceholder =\n placeholder.length > 0\n ? chalk.inverse(placeholder[0]) + chalk[colors.muted](placeholder.slice(1))\n : chalk.inverse(' ');\n\n renderedValue = value.length > 0 ? '' : chalk.inverse(' ');\n\n let i = 0;\n\n for (let char of value) {\n if (i >= state.cursorOffset && i <= state.cursorOffset) {\n renderedValue += chalk.inverse(char);\n } else {\n renderedValue += char;\n }\n\n i += 1;\n }\n\n if (value.length > 0 && state.cursorOffset === value.length) {\n renderedValue += chalk.inverse(' ');\n }\n }\n\n useInput(\n (input, key) => {\n if (\n key.upArrow ||\n key.downArrow ||\n (key.ctrl && input === 'c') ||\n (key.shift && key.tab) ||\n key.tab\n ) {\n return;\n }\n\n if (key.return) {\n if (onSubmit) {\n if (validate) {\n try {\n validate(originalValue);\n } catch (error: unknown) {\n setValidationError((error as Error).message);\n\n return;\n }\n }\n\n if (validationError) {\n setValidationError('');\n } else {\n onSubmit(originalValue);\n }\n }\n\n return;\n }\n\n let nextCursorOffset = state.cursorOffset;\n let nextValue = originalValue;\n let nextCursorWidth = 0;\n\n if (key.leftArrow) {\n if (showCursor) {\n nextCursorOffset -= 1;\n }\n } else if (key.rightArrow) {\n if (showCursor) {\n nextCursorOffset += 1;\n }\n } else if (key.backspace || key.delete) {\n if (state.cursorOffset > 0) {\n nextValue =\n originalValue.slice(0, state.cursorOffset - 1) +\n originalValue.slice(state.cursorOffset, originalValue.length);\n\n nextCursorOffset -= 1;\n }\n } else {\n nextValue =\n originalValue.slice(0, state.cursorOffset) +\n input +\n originalValue.slice(state.cursorOffset, originalValue.length);\n\n nextCursorOffset += input.length;\n\n if (input.length > 1) {\n nextCursorWidth = input.length;\n }\n }\n\n if (state.cursorOffset < 0) {\n nextCursorOffset = 0;\n }\n\n if (state.cursorOffset > originalValue.length) {\n nextCursorOffset = originalValue.length;\n }\n\n setState({\n cursorOffset: nextCursorOffset,\n cursorWidth: nextCursorWidth,\n });\n\n if (nextValue !== originalValue) {\n onChange(nextValue);\n }\n },\n {isActive: focus},\n );\n\n return (\n <Box {...boxProps}>\n <Box marginRight={1}>\n <Text>{isComplete ? icons.success : icons.question}</Text>\n </Box>\n\n <Box flexDirection=\"column\">\n <Box marginRight={1}>\n <Text color={colors.highlighted}>{label}</Text>\n </Box>\n {isComplete ? (\n <Text color={colors.body}>{value}</Text>\n ) : (\n <Text color={colors.highlighted}>\n {placeholder ? (value.length > 0 ? renderedValue : renderedPlaceholder) : renderedValue}\n </Text>\n )}\n {validationError ? (\n <Box marginTop={0}>\n <Text color={colors.warning}>{validationError}</Text>\n </Box>\n ) : null}\n </Box>\n </Box>\n );\n}\n"],"names":["chalk","Box","Text","useInput","useEffect","useState","colors","icons","TextInput","label","validate","isComplete","value","originalValue","placeholder","focus","mask","showCursor","onChange","onSubmit","boxProps","validationError","setValidationError","state","setState","cursorOffset","length","cursorWidth","previousState","newValue","repeat","renderedValue","renderedPlaceholder","muted","undefined","inverse","slice","i","char","input","key","upArrow","downArrow","ctrl","shift","tab","return","error","message","nextCursorOffset","nextValue","nextCursorWidth","leftArrow","rightArrow","backspace","delete","isActive","marginRight","success","question","flexDirection","color","highlighted","body","marginT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AAcuB,MAAM,GAAGb,MAAME,gBAC7Bc,QACA1B,cAAcuB,MAAMb,MAAME,cAAcZ,cAAca;YAExDuB,oBAAoBV,MAAMb;YAE1B,IAAIa,MAAMb,SAAS,GAAG;gBACpByB,kBAAkBZ,MAAMb;YAC1B;QACF;QAEA,IAAIH,MAAME,eAAe,GAAG;YAC1BwB,mBAAmB;QACrB;QAEA,IAAI1B,MAAME,eAAeZ,cAAca,QAAQ;YAC7CuB,mBAAmBpC,cAAca;QACnC;QAEAF,SAAS;YACPC,cAAcwB;YACdtB,aAAawB;QACf;QAEA,IAAID,cAAcrC,eAAe;YAC/BK,SAASgC;QACX;IACF,GACA;QAACM,UAAUzC;IAAK;IAGlB,qBACE,MAACd;QAAK,GAAGmB,QAAQ;;0BACf,KAACnB;gBAAIwD,aAAa;0BAChB,cAAA,KAACvD;8BAAMS,aAAaJ,MAAMmD,UAAUnD,MAAMoD;;;0BAG5C,MAAC1D;gBAAI2D,eAAc;;kCACjB,KAAC3D;wBAAIwD,aAAa;kCAChB,cAAA,KAACvD;4BAAK2D,OAAOvD,OAAOwD;sCAAcrD;;;oBAEnCE,2BACC,KAACT;wBAAK2D,OAAOvD,OAAOyD;kCAAOnD;uCAE3B,KAACV;wBAAK2D,OAAOvD,OAAOwD;kCACjBhD,cAAeF,MAAMc,SAAS,IAAIK,gBAAgBC,sBAAuBD;;oBAG7EV,gCACC,KAACpB;wBAAI+D,WAAW;kCACd,cAAA,KAAC9D;4BAAK2D,OAAOvD,OAAO2D;sCAAU5C;;yBAE9B;;;;;AAIZ"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type Form } from './Form.js';
|
|
2
|
+
import { type FormConfig } from './FormConfig.js';
|
|
3
|
+
/**
|
|
4
|
+
* Creates form component that contains individual rows with inputs based on the provided config.
|
|
5
|
+
*
|
|
6
|
+
* @param formConfig Form configuration.
|
|
7
|
+
* @returns Form component.
|
|
8
|
+
*/
|
|
9
|
+
export declare function createForm<C extends FormConfig>(formConfig: C): Form<C>;
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Box } from 'ink';
|
|
3
|
+
import { useCallback } from 'react';
|
|
4
|
+
import { FormRow } from './FormRow.js';
|
|
5
|
+
/**
|
|
6
|
+
* Creates form component that contains individual rows with inputs based on the provided config.
|
|
7
|
+
*
|
|
8
|
+
* @param formConfig Form configuration.
|
|
9
|
+
* @returns Form component.
|
|
10
|
+
*/ export function createForm(formConfig) {
|
|
11
|
+
let Form = ({ rows , values: results , onChange , onComplete: onFinish , ...boxProps })=>{
|
|
12
|
+
let handleChange = useCallback((value, rowName)=>{
|
|
13
|
+
if (onChange) {
|
|
14
|
+
onChange({
|
|
15
|
+
...results,
|
|
16
|
+
[rowName]: {
|
|
17
|
+
...results[rowName],
|
|
18
|
+
value
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
}, [
|
|
23
|
+
onChange,
|
|
24
|
+
results
|
|
25
|
+
]);
|
|
26
|
+
let handleFinish = useCallback((value, rowName)=>{
|
|
27
|
+
onFinish({
|
|
28
|
+
...results,
|
|
29
|
+
[rowName]: {
|
|
30
|
+
value,
|
|
31
|
+
isComplete: true
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
}, [
|
|
35
|
+
onFinish,
|
|
36
|
+
results
|
|
37
|
+
]);
|
|
38
|
+
let inputElements = [];
|
|
39
|
+
let activeInputName = null;
|
|
40
|
+
for (let [rowName] of Object.entries(formConfig.rows)){
|
|
41
|
+
if (!results[rowName].isComplete) {
|
|
42
|
+
activeInputName = String(rowName);
|
|
43
|
+
break;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
for (let [rowName, input] of Object.entries(formConfig.rows)){
|
|
47
|
+
if (results[rowName].isComplete || rowName === activeInputName) {
|
|
48
|
+
inputElements.push(/*#__PURE__*/ _jsx(FormRow, {
|
|
49
|
+
marginTop: inputElements.length === 0 ? 0 : 1,
|
|
50
|
+
focus: rowName === activeInputName,
|
|
51
|
+
isComplete: results[rowName].isComplete,
|
|
52
|
+
config: input,
|
|
53
|
+
rows: rows,
|
|
54
|
+
rowName: rowName,
|
|
55
|
+
value: results[rowName].value,
|
|
56
|
+
onChange: handleChange,
|
|
57
|
+
onComplete: handleFinish
|
|
58
|
+
}, rowName));
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
return /*#__PURE__*/ _jsx(Box, {
|
|
62
|
+
...boxProps,
|
|
63
|
+
flexDirection: "column",
|
|
64
|
+
children: inputElements
|
|
65
|
+
});
|
|
66
|
+
};
|
|
67
|
+
return Object.assign(Form, {
|
|
68
|
+
config: formConfig
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
//# sourceMappingURL=createForm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/ui/form/createForm.tsx"],"sourcesContent":["import {Box, type BoxProps} from 'ink';\nimport {useCallback} from 'react';\n\nimport {type Form} from './Form.js';\nimport {type FormConfig} from './FormConfig.js';\nimport {type FormProps} from './FormProps.js';\nimport {FormRow} from './FormRow.js';\n\n/**\n * Creates form component that contains individual rows with inputs based on the provided config.\n *\n * @param formConfig Form configuration.\n * @returns Form component.\n */\nexport function createForm<C extends FormConfig>(formConfig: C): Form<C> {\n let Form = ({\n rows,\n values: results,\n onChange,\n onComplete: onFinish,\n ...boxProps\n }: FormProps<C>) => {\n let handleChange = useCallback(\n (value: unknown, rowName: keyof C['rows']) => {\n if (onChange) {\n onChange({\n ...results,\n [rowName]: {\n ...results[rowName],\n value,\n },\n });\n }\n },\n [onChange, results],\n );\n\n let handleFinish = useCallback(\n (value: unknown, rowName: keyof C['rows']) => {\n onFinish({\n ...results,\n [rowName]: {\n value,\n isComplete: true,\n },\n });\n },\n [onFinish, results],\n );\n\n let inputElements = [];\n let activeInputName: string | null = null;\n\n for (let [rowName] of Object.entries(formConfig.rows)) {\n if (!results[rowName as keyof C['rows']].isComplete) {\n activeInputName = String(rowName);\n\n break;\n }\n }\n\n for (let [rowName, input] of Object.entries(formConfig.rows)) {\n if (results[rowName as keyof C['rows']].isComplete || rowName === activeInputName) {\n inputElements.push(\n <FormRow\n key={rowName}\n marginTop={inputElements.length === 0 ? 0 : 1}\n focus={rowName === activeInputName}\n isComplete={results[rowName as keyof C['rows']].isComplete}\n config={input}\n rows={rows}\n rowName={rowName}\n value={results[rowName as keyof C['rows']].value}\n onChange={handleChange}\n onComplete={handleFinish}\n />,\n );\n }\n }\n\n return (\n <Box {...(boxProps as BoxProps)} flexDirection=\"column\">\n {inputElements}\n </Box>\n );\n };\n\n return Object.assign(Form, {config: formConfig});\n}\n"],"names":["Box","useCallback","FormRow","createForm","formConfig","Form","rows","values","results","onChange","onComplete","onFinish","boxProps","handleChange","value","rowName","handleFinish","isComplete","inputElements","activeInputName","Object","entries","String","input","push","marginTop","length","focus","config","flexDirection","assign"],"mappings":";AAAA,SAAQA,GAAG,QAAsB,MAAM;AACvC,SAAQC,WAAW,QAAO,QAAQ;AAKlC,SAAQC,OAAO,QAAO,eAAe;AAErC;;;;;CAKC,GACD,OAAO,SAASC,WAAiCC,UAAa;IAC5D,IAAIC,OAAO,CAAC,EACVC,KAAI,EACJC,QAAQC,QAAO,EACfC,SAAQ,EACRC,YAAYC,SAAQ,EACpB,GAAGC,UACU;QACb,IAAIC,eAAeZ,YACjB,CAACa,OAAgBC;YACf,IAAIN,UAAU;gBACZA,SAAS;oBACP,GAAGD,OAAO;oBACV,CAACO,QAAQ,EAAE;wBACT,GAAGP,OAAO,CAACO,QAAQ;wBACnBD;oBACF;gBACF;YACF;QACF,GACA;YAACL;YAAUD;SAAQ;QAGrB,IAAIQ,eAAef,YACjB,CAACa,OAAgBC;YACfJ,SAAS;gBACP,GAAGH,OAAO;gBACV,CAACO,QAAQ,EAAE;oBACTD;oBACAG,YAAY;gBACd;YACF;QACF,GACA;YAACN;YAAUH;SAAQ;QAGrB,IAAIU,gBAAgB,EAAE;QACtB,IAAIC,kBAAiC;QAErC,KAAK,IAAI,CAACJ,QAAQ,IAAIK,OAAOC,QAAQjB,WAAWE,MAAO;YACrD,IAAI,CAACE,OAAO,CAACO,QAA2B,CAACE,YAAY;gBACnDE,kBAAkBG,OAAOP;gBAEzB;YACF;QACF;QAEA,KAAK,IAAI,CAACA,SAASQ,MAAM,IAAIH,OAAOC,QAAQjB,WAAWE,MAAO;YAC5D,IAAIE,OAAO,CAACO,QAA2B,CAACE,cAAcF,YAAYI,iBAAiB;gBACjFD,cAAcM,mBACZ,KAACtB;oBAECuB,WAAWP,cAAcQ,WAAW,IAAI,IAAI;oBAC5CC,OAAOZ,YAAYI;oBACnBF,YAAYT,OAAO,CAACO,QAA2B,CAACE;oBAChDW,QAAQL;oBACRjB,MAAMA;oBACNS,SAASA;oBACTD,OAAON,OAAO,CAACO,QAA2B,CAACD;oBAC3CL,UAAUI;oBACVH,YAAYM;mBATPD;YAYX;QACF;QAEA,qBACE,KAACf;YAAK,GAAIY,QAAQ;YAAeiB,eAAc;sBAC5CX;;IAGP;IAEA,OAAOE,OAAOU,OAAOzB,MAAM;QAACuB,QAAQxB;IAAU;AAChD"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export * from './form/Form.js';
|
|
2
|
+
export * from './form/FormConfig.js';
|
|
3
|
+
export * from './form/FormProps.js';
|
|
4
|
+
export * from './form/FormRowConfig.js';
|
|
5
|
+
export * from './form/FormRowsConfig.js';
|
|
6
|
+
export * from './form/FormValue.js';
|
|
7
|
+
export * from './form/FormValues.js';
|
|
8
|
+
export * from './form/FormResult.js';
|
|
9
|
+
export * from './form/createForm.js';
|
|
10
|
+
export * from './form/FormRow.js';
|
|
11
|
+
export * from './form/SelectInput.js';
|
|
12
|
+
export * from './form/SelectInputItem.js';
|
|
13
|
+
export * from './form/TextInput.js';
|
package/dist/ui/form.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export * from './form/Form.js';
|
|
2
|
+
export * from './form/FormConfig.js';
|
|
3
|
+
export * from './form/FormProps.js';
|
|
4
|
+
export * from './form/FormRowConfig.js';
|
|
5
|
+
export * from './form/FormRowsConfig.js';
|
|
6
|
+
export * from './form/FormValue.js';
|
|
7
|
+
export * from './form/FormValues.js';
|
|
8
|
+
export * from './form/FormResult.js';
|
|
9
|
+
export * from './form/createForm.js';
|
|
10
|
+
export * from './form/FormRow.js';
|
|
11
|
+
export * from './form/SelectInput.js';
|
|
12
|
+
export * from './form/SelectInputItem.js';
|
|
13
|
+
export * from './form/TextInput.js';
|
|
14
|
+
|
|
15
|
+
//# sourceMappingURL=form.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/ui/form.ts"],"sourcesContent":["export * from './form/Form.js';\nexport * from './form/FormConfig.js';\nexport * from './form/FormProps.js';\nexport * from './form/FormRowConfig.js';\nexport * from './form/FormRowsConfig.js';\nexport * from './form/FormValue.js';\nexport * from './form/FormValues.js';\nexport * from './form/FormResult.js';\nexport * from './form/createForm.js';\nexport * from './form/FormRow.js';\nexport * from './form/SelectInput.js';\nexport * from './form/SelectInputItem.js';\nexport * from './form/TextInput.js';\n"],"names":[],"mappings":"AAAA,cAAc,iBAAiB;AAC/B,cAAc,uBAAuB;AACrC,cAAc,sBAAsB;AACpC,cAAc,0BAA0B;AACxC,cAAc,2BAA2B;AACzC,cAAc,sBAAsB;AACpC,cAAc,uBAAuB;AACrC,cAAc,uBAAuB;AACrC,cAAc,uBAAuB;AACrC,cAAc,oBAAoB;AAClC,cAAc,wBAAwB;AACtC,cAAc,4BAA4B;AAC1C,cAAc,sBAAsB"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { ValidationError, ParsingError } from '@jakubmazanec/args';
|
|
2
|
+
/**
|
|
3
|
+
* Creates detailed information about an error.
|
|
4
|
+
*/ export function getErrorDetail(error) {
|
|
5
|
+
// TODO: add all codes
|
|
6
|
+
if (error instanceof ParsingError) {
|
|
7
|
+
switch(error.code){
|
|
8
|
+
default:
|
|
9
|
+
{
|
|
10
|
+
return {
|
|
11
|
+
label: 'Parsing error',
|
|
12
|
+
description: error.message
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
// TODO: add all codes
|
|
18
|
+
if (error instanceof ValidationError) {
|
|
19
|
+
switch(error.code){
|
|
20
|
+
default:
|
|
21
|
+
{
|
|
22
|
+
return {
|
|
23
|
+
label: 'Validation error',
|
|
24
|
+
description: error.message
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
// TODO: add all built-in errors
|
|
30
|
+
if (error instanceof ReferenceError) {
|
|
31
|
+
let errorDetail = {
|
|
32
|
+
label: 'Error',
|
|
33
|
+
description: error.message
|
|
34
|
+
};
|
|
35
|
+
if (error.stack) {
|
|
36
|
+
errorDetail.stack = error.stack;
|
|
37
|
+
}
|
|
38
|
+
return errorDetail;
|
|
39
|
+
}
|
|
40
|
+
if (error instanceof Error) {
|
|
41
|
+
let errorDetail = {
|
|
42
|
+
label: 'Error',
|
|
43
|
+
description: error.message
|
|
44
|
+
};
|
|
45
|
+
if (error.stack) {
|
|
46
|
+
errorDetail.stack = error.stack;
|
|
47
|
+
}
|
|
48
|
+
if (error.cause instanceof Error) {
|
|
49
|
+
errorDetail.cause = {
|
|
50
|
+
description: error.cause.message
|
|
51
|
+
};
|
|
52
|
+
if (error.cause.stack) {
|
|
53
|
+
errorDetail.cause.stack = error.cause.stack;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
return errorDetail;
|
|
57
|
+
}
|
|
58
|
+
return {
|
|
59
|
+
label: 'Error'
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
//# sourceMappingURL=getErrorDetail.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/ui/getErrorDetail.ts"],"sourcesContent":["import {ValidationError, ParsingError} from '@jakubmazanec/args';\n\nimport {type ErrorDetail} from './ErrorDetail.js';\n\n/**\n * Creates detailed information about an error.\n */\nexport function getErrorDetail(error: unknown): ErrorDetail {\n // TODO: add all codes\n if (error instanceof ParsingError) {\n switch (error.code) {\n default: {\n return {\n label: 'Parsing error',\n description: error.message,\n };\n }\n }\n }\n\n // TODO: add all codes\n if (error instanceof ValidationError) {\n switch (error.code) {\n default: {\n return {\n label: 'Validation error',\n description: error.message,\n };\n }\n }\n }\n\n // TODO: add all built-in errors\n if (error instanceof ReferenceError) {\n let errorDetail: ErrorDetail = {\n label: 'Error',\n description: error.message,\n };\n\n if (error.stack) {\n errorDetail.stack = error.stack;\n }\n\n return errorDetail;\n }\n\n if (error instanceof Error) {\n let errorDetail: ErrorDetail = {\n label: 'Error',\n description: error.message,\n };\n\n if (error.stack) {\n errorDetail.stack = error.stack;\n }\n\n if (error.cause instanceof Error) {\n errorDetail.cause = {\n description: error.cause.message,\n };\n\n if (error.cause.stack) {\n errorDetail.cause.stack = error.cause.stack;\n }\n }\n\n return errorDetail;\n }\n\n return {\n label: 'Error',\n };\n}\n"],"names":["ValidationError","ParsingError","getErrorDetail","error","code","label","description","message","ReferenceError","errorDetail","stack","Error","cause"],"mappings":"AAAA,SAAQA,eAAe,EAAEC,YAAY,QAAO,qBAAqB;AAIjE;;CAEC,GACD,OAAO,SAASC,eAAeC,KAAc;IAC3C,sBAAsB;IACtB,IAAIA,iBAAiBF,cAAc;QACjC,OAAQE,MAAMC;YACZ;gBAAS;oBACP,OAAO;wBACLC,OAAO;wBACPC,aAAaH,MAAMI;oBACrB;gBACF;QACF;IACF;IAEA,sBAAsB;IACtB,IAAIJ,iBAAiBH,iBAAiB;QACpC,OAAQG,MAAMC;YACZ;gBAAS;oBACP,OAAO;wBACLC,OAAO;wBACPC,aAAaH,MAAMI;oBACrB;gBACF;QACF;IACF;IAEA,gCAAgC;IAChC,IAAIJ,iBAAiBK,gBAAgB;QACnC,IAAIC,cAA2B;YAC7BJ,OAAO;YACPC,aAAaH,MAAMI;QACrB;QAEA,IAAIJ,MAAMO,OAAO;YACfD,YAAYC,QAAQP,MAAMO;QAC5B;QAEA,OAAOD;IACT;IAEA,IAAIN,iBAAiBQ,OAAO;QAC1B,IAAIF,cAA2B;YAC7BJ,OAAO;YACPC,aAAaH,MAAMI;QACrB;QAEA,IAAIJ,MAAMO,OAAO;YACfD,YAAYC,QAAQP,MAAMO;QAC5B;QAEA,IAAIP,MAAMS,iBAAiBD,OAAO;YAChCF,YAAYG,QAAQ;gBAClBN,aAAaH,MAAMS,MAAML;YAC3B;YAEA,IAAIJ,MAAMS,MAAMF,OAAO;gBACrBD,YAAYG,MAAMF,QAAQP,MAAMS,MAAMF;YACxC;QACF;QAEA,OAAOD;IACT;IAEA,OAAO;QACLJ,OAAO;IACT;AACF"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare const question: string;
|
|
2
|
+
export declare const info: string;
|
|
3
|
+
export declare const success: string;
|
|
4
|
+
export declare const warning: string;
|
|
5
|
+
export declare const error: string;
|
|
6
|
+
export declare const unselectedSquare: string;
|
|
7
|
+
export declare const selectedSquare: string;
|
|
8
|
+
export declare const unselectedCircle: string;
|
|
9
|
+
export declare const selectedCircle: string;
|
package/dist/ui/icons.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import chalk from 'chalk';
|
|
2
|
+
import * as colors from './colors.js';
|
|
3
|
+
export const question = chalk[colors.notice]('?');
|
|
4
|
+
export const info = chalk[colors.info]('i');
|
|
5
|
+
export const success = chalk[colors.success]('✓');
|
|
6
|
+
export const warning = chalk[colors.warning]('▲');
|
|
7
|
+
export const error = chalk[colors.failure]('×');
|
|
8
|
+
export const unselectedSquare = chalk[colors.unselected]('◻');
|
|
9
|
+
export const selectedSquare = chalk[colors.selected]('◼');
|
|
10
|
+
export const unselectedCircle = chalk[colors.unselected]('○');
|
|
11
|
+
export const selectedCircle = chalk[colors.selected]('●');
|
|
12
|
+
|
|
13
|
+
//# sourceMappingURL=icons.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/ui/icons.ts"],"sourcesContent":["import chalk from 'chalk';\n\nimport * as colors from './colors.js';\n\nexport const question = chalk[colors.notice]('?');\nexport const info = chalk[colors.info]('i');\nexport const success = chalk[colors.success]('✓');\nexport const warning = chalk[colors.warning]('▲');\nexport const error = chalk[colors.failure]('×');\nexport const unselectedSquare = chalk[colors.unselected]('◻');\nexport const selectedSquare = chalk[colors.selected]('◼');\nexport const unselectedCircle = chalk[colors.unselected]('○');\nexport const selectedCircle = chalk[colors.selected]('●');\n"],"names":["chalk","colors","question","notice","info","success","warning","error","failure","unselectedSquare","unselected","selectedSquare","selected","unselectedCircle","selectedCircle"],"mappings":"AAAA,OAAOA,WAAW,QAAQ;AAE1B,YAAYC,YAAY,cAAc;AAEtC,OAAO,MAAMC,WAAWF,KAAK,CAACC,OAAOE,OAAO,CAAC,KAAK;AAClD,OAAO,MAAMC,OAAOJ,KAAK,CAACC,OAAOG,KAAK,CAAC,KAAK;AAC5C,OAAO,MAAMC,UAAUL,KAAK,CAACC,OAAOI,QAAQ,CAAC,KAAK;AAClD,OAAO,MAAMC,UAAUN,KAAK,CAACC,OAAOK,QAAQ,CAAC,KAAK;AAClD,OAAO,MAAMC,QAAQP,KAAK,CAACC,OAAOO,QAAQ,CAAC,KAAK;AAChD,OAAO,MAAMC,mBAAmBT,KAAK,CAACC,OAAOS,WAAW,CAAC,KAAK;AAC9D,OAAO,MAAMC,iBAAiBX,KAAK,CAACC,OAAOW,SAAS,CAAC,KAAK;AAC1D,OAAO,MAAMC,mBAAmBb,KAAK,CAACC,OAAOS,WAAW,CAAC,KAAK;AAC9D,OAAO,MAAMI,iBAAiBd,KAAK,CAACC,OAAOW,SAAS,CAAC,KAAK"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type FC, type PropsWithChildren } from 'react';
|
|
2
|
+
import { type Program } from '../../program.js';
|
|
3
|
+
/**
|
|
4
|
+
* {@linkcode Wrapper} component props.
|
|
5
|
+
*/
|
|
6
|
+
export type WrapperProps = {
|
|
7
|
+
program: Program;
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* A component that wraps anything {@linkcode Program} tries to render with an error boundary and all neccessary providers.
|
|
11
|
+
*/
|
|
12
|
+
export declare const Wrapper: FC<PropsWithChildren<WrapperProps>>;
|