Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
4d94642
feat: Upgraded package versions for NodeJS types, react, ink and ink …
kevinwang5658 Jan 28, 2025
b0912d4
feat: Added initial values
kevinwang5658 Jan 28, 2025
ce1dae5
feat: Added fullscreen and scroll
kevinwang5658 Jan 28, 2025
00a866a
feat: Refactored scroll area and improved it to reset the scroll posi…
kevinwang5658 Jan 28, 2025
c5da68d
fix: Fixed header ref for calculating the header height
kevinwang5658 Jan 28, 2025
161a7e2
feat: Altered layout and UI to look more like a JSON object
kevinwang5658 Jan 29, 2025
2cff2cc
feat: Render undefined if value doesn't exist. Added codify test file
kevinwang5658 Jan 29, 2025
1963079
feat: Improved canSubmit button by making it green when it can be sub…
kevinwang5658 Jan 29, 2025
cd89453
feat: Changed submit text to be green as well
kevinwang5658 Jan 29, 2025
5be9e6f
feat: Fixed esc button not functioning
kevinwang5658 Jan 29, 2025
9889d8b
fix: Fixed fullscreen bugs and added additional tests
kevinwang5658 Jan 29, 2025
b95db3b
feat: Refactored and improved the dimension readngs (moved to a hook)…
kevinwang5658 Jan 29, 2025
086ee77
fix: Fixed add and remove logic. Added comments.
kevinwang5658 Jan 29, 2025
6f6911f
fix: Fixed exit behaviour
kevinwang5658 Jan 29, 2025
93dd7b0
fix: Disabled mouse events in editing mode
kevinwang5658 Jan 29, 2025
1229510
feat: Added array support. Added a type description for every field. …
kevinwang5658 Jan 29, 2025
dd0de53
feat: Improved copy for navigation helper and the submit button
kevinwang5658 Jan 30, 2025
d9c0012
fix: Fixed escape behaviour on the main page (now it will reset focus…
kevinwang5658 Jan 30, 2025
bddf98b
fix: Fixed bug with removing the first element. Also disabled remove …
kevinwang5658 Jan 30, 2025
ea46036
fix: Fixed type errors and updated package.json
kevinwang5658 Jan 30, 2025
7384bd8
fix: Fixed calculations for scrolling and focus position
kevinwang5658 Jan 30, 2025
1df7b37
feat: Improved how description is shown and improved margins
kevinwang5658 Jan 30, 2025
05f8b2a
feat: Improved submit output
kevinwang5658 Jan 31, 2025
b3409c9
fix: Fixed typing for form return values
kevinwang5658 Jan 31, 2025
2db86ad
feat: Changed how tab changes on adding and deleting elements
kevinwang5658 Feb 17, 2025
a14ff6c
feat: Added description for properties in the main page
kevinwang5658 Feb 17, 2025
ff312f1
Re-arranged UI
kevinwang5658 Feb 26, 2025
0bdeb11
Added helpful descriptions to make ui less confusing
kevinwang5658 Feb 26, 2025
aed1209
Added wrapping for header if it gets too long
kevinwang5658 Feb 26, 2025
2f3c142
UX improvements
kevinwang5658 Feb 26, 2025
8b61f27
UX improvements 2
kevinwang5658 Feb 26, 2025
7bebafd
UX improvements 3. The highlighting was making the text very hard to …
kevinwang5658 Feb 26, 2025
b3c65d5
Remove highlights to make codify config easier to see
kevinwang5658 Apr 6, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file removed next-releasenotes.md
Empty file.
41 changes: 22 additions & 19 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"name": "ink-form",
"name": "@codifycli/ink-form",
"type": "module",
"version": "2.0.1",
"description": "Complex user-friendly form component for React Ink",
"version": "0.0.11",
"description": "Complex user-friendly form component for Codify",
"main": "lib/index.js",
"exports": "./lib/index.js",
"types": "lib/index.d.ts",
Expand All @@ -18,44 +18,47 @@
"commandline",
"cmd"
],
"repository": "https://github.com/lukasbach/ink-form",
"author": "Lukas Bach <lbach@outlook.de>",
"license": "MIT",
"bugs": "https://github.com/lukasbach/ink-form/issues",
"repository": "https://github.com/codifyCLI/codify-ink-form",
"author": "Lukas Bach <lbach@outlook.de> modified by Kevin Wang",
"devDependencies": {
"@types/node": "^14.14.45",
"@types/node": "20.14.8",
"@types/react": "^18.2.41",
"ink": "^4.4.1",
"ink": "^5.1.0",
"prettier": "^2.2.1",
"publish-fast": "^0.0.20",
"react": "^18.2.0",
"ts-node": "^10.9.1",
"tsx": "^4.19.2",
"typedoc": "^0.25.4",
"typescript": "^5.3.2"
"typescript": "^5.3.2",
"react-devtools-core": "4.28.5"
},
"scripts": {
"start": "ts-node-esm src/demo/overview.tsx",
"demo:overview": "ts-node-esm src/demo/overview.tsx",
"demo:packagejson": "ts-node-esm src/demo/packagejson.tsx",
"demo:custommanager": "ts-node-esm src/demo/custommanager.tsx",
"demo:imperative": "ts-node-esm src/demo/imperative.ts",
"demo:overview": "tsx src/demo/overview.tsx",
"demo:counter": "tsx src/demo/counter.tsx",
"demo:codify": "tsx src/demo/codify.tsx",
"demo:packagejson": "tsx src/demo/packagejson.tsx",
"demo:custommanager": "tsx src/demo/custommanager.tsx",
"demo:imperative": "tsx src/demo/imperative.ts",
"build": "tsc",
"build:docs": "typedoc --out docs src/index.ts",
"lint": "prettier --check .",
"prettier:check": "prettier --check .",
"prettier:write": "prettier --write .",
"release": "publish-fast"
"release": "publish-fast",
"prepublishOnly": "tsc"
},
"peerDependencies": {
"ink": ">=4",
"ink": ">=5",
"react": ">=18"
},
"dependencies": {
"ink-select-input": "^5.0.0",
"ink-select-input": "^6.0.0",
"ink-text-input": "^6.0.0"
},
"publishConfig": {
"access": "public"
"access": "restricted",
"registry": "https://npm.pkg.github.com"
},
"publish": {
"preScripts": "build,build:docs,lint",
Expand Down
39 changes: 39 additions & 0 deletions src/ArrayFieldRenderer.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import React from 'react';
import { FormFieldArray, SpecificFormFieldRendererProps } from './types.js';
import { Box } from 'ink';
import TextInput from 'ink-text-input';

export const ArrayFieldRenderer: React.FC<
SpecificFormFieldRendererProps<FormFieldArray>
> = props => {
const regex = props.field.regex;

const change = (value: string) => {
if (regex) {
const arr = value.split(/(?<!\\),/);

if (arr.some((i) => !regex.test(i))) {
props.onError(`"${value}" does not pass the regex ${regex}`);
props.onChange(value as any);
}
} else {
props.onChange(value as any);
}
};

return (
<Box borderStyle={'round'} width="100%" flexDirection="column">
<Box>
<TextInput
value={props.value?.toString() ?? ''}
onChange={value => {
props.onClearError();
change(value);
}}
placeholder={props.field.placeholder ?? 'value1, value2, value3...'}
onSubmit={() => props.onSetEditingField(undefined)}
/>
</Box>
</Box>
);
};
30 changes: 30 additions & 0 deletions src/Button.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { Box, Text, useFocus, useInput } from 'ink';
import React from 'react';

export function Button(props: {
label: string;
onClicked?: () => void;
id?: string;
isEnabled?: boolean;
}) {
const isEnabled = props.isEnabled ?? true;
const { isFocused } = useFocus({ ...(props.id ? { id: props.id } : {}), isActive: props.isEnabled });

useInput((input, key) => {
if (!isEnabled) {
return;
}

if (key.return && isFocused) {
props.onClicked?.();
}
});

return <Box borderStyle="round" borderColor={!isEnabled ? 'gray' : isFocused ? 'blue' : 'magenta'}>
<Box flexGrow={1}>
<Text underline={isFocused} color={isFocused ? 'blue' : undefined}>
{props.label}
</Text>
</Box>
</Box>
}
Loading
Loading