ag-toolkit 0.1.0 → 0.1.2
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/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# aglib
|
|
2
2
|
|
|
3
|
-
`aglib` is a library that provides shared functionality for the
|
|
3
|
+
`aglib` is a library that provides shared functionality for the [agbd](https://github.com/riya-amemiya/agbd) and [agrb](https://github.com/riya-amemiya/agrb) CLI tools.
|
|
4
4
|
|
|
5
5
|
## Features Included
|
|
6
6
|
|
|
@@ -57,7 +57,7 @@ export const ConfigEditor = ({ toolName, configItems, defaultConfig, loadConfig,
|
|
|
57
57
|
: [];
|
|
58
58
|
const handleSelect = (selected) => {
|
|
59
59
|
const item = configItems.find((i) => i.key === selected.value);
|
|
60
|
-
if (!config
|
|
60
|
+
if (!(config && item)) {
|
|
61
61
|
return;
|
|
62
62
|
}
|
|
63
63
|
setEditingItem(item);
|
|
@@ -81,8 +81,9 @@ export const ConfigEditor = ({ toolName, configItems, defaultConfig, loadConfig,
|
|
|
81
81
|
setStatus("selecting");
|
|
82
82
|
};
|
|
83
83
|
const commitEditing = () => {
|
|
84
|
-
if (!config
|
|
84
|
+
if (!(config && editingItem)) {
|
|
85
85
|
return;
|
|
86
|
+
}
|
|
86
87
|
const { key, type } = editingItem;
|
|
87
88
|
let nextValue;
|
|
88
89
|
switch (type) {
|
|
@@ -120,8 +121,9 @@ export const ConfigEditor = ({ toolName, configItems, defaultConfig, loadConfig,
|
|
|
120
121
|
cancelEditing();
|
|
121
122
|
};
|
|
122
123
|
useInput((input, key) => {
|
|
123
|
-
if (status !== "editing" || !editingItem)
|
|
124
|
+
if (status !== "editing" || !editingItem) {
|
|
124
125
|
return;
|
|
126
|
+
}
|
|
125
127
|
if (key.escape) {
|
|
126
128
|
cancelEditing();
|
|
127
129
|
return;
|
|
@@ -163,8 +165,9 @@ export const ConfigEditor = ({ toolName, configItems, defaultConfig, loadConfig,
|
|
|
163
165
|
}
|
|
164
166
|
};
|
|
165
167
|
const renderEditor = () => {
|
|
166
|
-
if (!editingItem)
|
|
168
|
+
if (!editingItem) {
|
|
167
169
|
return null;
|
|
170
|
+
}
|
|
168
171
|
switch (editingItem.type) {
|
|
169
172
|
case "boolean":
|
|
170
173
|
return (_jsxs(Box, { flexDirection: "column", children: [_jsxs(Text, { children: ["Set value for \"", String(editingItem.key), "\":"] }), _jsx(SelectInput, { items: [
|
|
@@ -180,10 +183,12 @@ export const ConfigEditor = ({ toolName, configItems, defaultConfig, loadConfig,
|
|
|
180
183
|
case "number":
|
|
181
184
|
case "array": {
|
|
182
185
|
let prompt = "Enter a string";
|
|
183
|
-
if (editingItem.type === "number")
|
|
186
|
+
if (editingItem.type === "number") {
|
|
184
187
|
prompt = "Enter a number (>= 0)";
|
|
185
|
-
|
|
188
|
+
}
|
|
189
|
+
if (editingItem.type === "array") {
|
|
186
190
|
prompt = "Enter comma-separated values";
|
|
191
|
+
}
|
|
187
192
|
return (_jsxs(Box, { flexDirection: "column", children: [_jsxs(Text, { children: [prompt, " (leave empty to unset):"] }), _jsx(Text, { color: "cyan", children: inputBuffer || "<empty>" }), _jsx(Text, { color: "gray", children: "Enter: save / Esc: cancel" }), inputError && _jsx(Text, { color: "red", children: inputError })] }));
|
|
188
193
|
}
|
|
189
194
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const useSearchFilter: <T extends Record<string,
|
|
1
|
+
export declare const useSearchFilter: <T extends Record<string, unknown>>(items: T[], searchTerm: string, searchableFields: (keyof T)[]) => T[];
|