Skip to content

Commit a59b5b0

Browse files
committed
refactor: Minor cleanup
1 parent b1004b1 commit a59b5b0

21 files changed

+418
-513
lines changed

.prettierrc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"useTabs": true,
3+
"tabWidth": 4,
4+
"printWidth": 120,
5+
"singleQuote": true,
6+
"trailingComma": "es5"
7+
}

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
## v0.3.0 (11-06-2025)
2+
3+
**Note:**
4+
Minor plugin update and keyword changes.
5+
16
## v0.2.0 (26-02-2024)
27

38
**Breaking Changes:**

package-lock.json

Lines changed: 26 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,15 @@
33
"homepage": "https://github.com/React-ChatBotify-Plugins/input-validator",
44
"keywords": [
55
"react",
6-
"chat",
7-
"chatbot",
8-
"conversational-bot",
9-
"conversational-ui",
106
"frontend-library",
11-
"plugins"
7+
"plugins",
8+
"react-chatbotify",
9+
"react-chatbotify-plugin"
1210
],
1311
"files": [
1412
"./dist"
1513
],
16-
"version": "0.2.0",
14+
"version": "0.3.0",
1715
"description": "A lightweight plugin to validate user input with visual feedbacks in React ChatBotify!",
1816
"type": "module",
1917
"main": "./dist/index.cjs",
@@ -32,7 +30,8 @@
3230
"scripts": {
3331
"start": "vite serve",
3432
"build": "tsc -b && vite build",
35-
"lint": "eslint .",
33+
"lint": "eslint --fix \"**/*.{ts,tsx}\"",
34+
"format": "prettier --write \"{src,test,types}/**/*.{ts,tsx,js,json,md}\"",
3635
"preview": "vite preview",
3736
"prepack": "tsc && vite build",
3837
"unit:test": "jest __tests__/"
@@ -45,6 +44,7 @@
4544
},
4645
"peerDependencies": {
4746
"react": "^18.3.1",
47+
"react-chatbotify": "^2.0.0-beta.38",
4848
"react-dom": "^18.3.1"
4949
},
5050
"devDependencies": {
@@ -61,9 +61,9 @@
6161
"globals": "^15.9.0",
6262
"identity-obj-proxy": "^3.0.0",
6363
"jest": "^29.7.0",
64-
"ts-jest": "^29.2.6",
6564
"jest-environment-jsdom": "^29.7.0",
66-
"react-chatbotify": "^2.0.0-beta.24",
65+
"prettier": "^3.5.3",
66+
"ts-jest": "^29.2.6",
6767
"typescript": "^5.5.3",
6868
"typescript-eslint": "^8.7.0",
6969
"vite": "^5.4.8",

src/App.tsx

Lines changed: 57 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -1,62 +1,57 @@
1-
import ChatBot, { Flow } from "react-chatbotify";
2-
3-
import RcbPlugin from "./factory/RcbPluginFactory";
4-
import { InputValidatorBlock } from "./types/InputValidatorBlock";
5-
import { validateFile } from "./utils/validateFile";
6-
7-
const App = () => {
8-
// Initialize the plugin
9-
const plugins = [RcbPlugin()];
10-
11-
// Example flow for testing
12-
const flow: Flow = {
13-
start: {
14-
message: "Hey there! Please enter your age.",
15-
path: "age_validation",
16-
validateTextInput: (userInput?: string) => {
17-
if (userInput && !Number.isNaN(Number(userInput))) {
18-
return { success: true };
19-
}
20-
return {
21-
success: false,
22-
promptContent: "Age must be a number!",
23-
promptDuration: 3000,
24-
promptType: "error",
25-
highlightTextArea: true,
26-
};
27-
},
28-
} as InputValidatorBlock,
29-
30-
age_validation: {
31-
message:
32-
"Great! Now please upload a profile picture (JPEG or PNG) or provide a URL.",
33-
path: "file_upload_validation",
34-
chatDisabled: true, // Text input is disabled
35-
validateFileInput: (file?: File) => {
36-
return validateFile(file); // Validation is handled here
37-
},
38-
file: async ({ files }) => {
39-
console.log("Files received:", files);
40-
41-
if (files && files[0]) {
42-
console.log("File uploaded successfully:", files[0]);
43-
} else {
44-
console.error("No file provided.");
45-
}
46-
},
47-
} as InputValidatorBlock,
48-
49-
50-
file_upload_validation: {
51-
message:
52-
"Thank you! Your input has been received. You passed the validation!",
53-
path: "start",
54-
},
55-
};
56-
57-
return (
58-
<ChatBot id="chatbot-id" plugins={plugins} flow={flow}></ChatBot>
59-
);
60-
};
61-
62-
export default App;
1+
import ChatBot, { Flow } from 'react-chatbotify';
2+
3+
import RcbPlugin from './factory/RcbPluginFactory';
4+
import { InputValidatorBlock } from './types/InputValidatorBlock';
5+
import { validateFile } from './utils/validateFile';
6+
7+
const App = () => {
8+
// Initialize the plugin
9+
const plugins = [RcbPlugin()];
10+
11+
// Example flow for testing
12+
const flow: Flow = {
13+
start: {
14+
message: 'Hey there! Please enter your age.',
15+
path: 'age_validation',
16+
validateTextInput: (userInput?: string) => {
17+
if (userInput && !Number.isNaN(Number(userInput))) {
18+
return { success: true };
19+
}
20+
return {
21+
success: false,
22+
promptContent: 'Age must be a number!',
23+
promptDuration: 3000,
24+
promptType: 'error',
25+
highlightTextArea: true,
26+
};
27+
},
28+
} as InputValidatorBlock,
29+
30+
age_validation: {
31+
message: 'Great! Now please upload a profile picture (JPEG or PNG) or provide a URL.',
32+
path: 'file_upload_validation',
33+
chatDisabled: true, // Text input is disabled
34+
validateFileInput: (file?: File) => {
35+
return validateFile(file); // Validation is handled here
36+
},
37+
file: async ({ files }) => {
38+
console.log('Files received:', files);
39+
40+
if (files && files[0]) {
41+
console.log('File uploaded successfully:', files[0]);
42+
} else {
43+
console.error('No file provided.');
44+
}
45+
},
46+
} as InputValidatorBlock,
47+
48+
file_upload_validation: {
49+
message: 'Thank you! Your input has been received. You passed the validation!',
50+
path: 'start',
51+
},
52+
};
53+
54+
return <ChatBot id="chatbot-id" plugins={plugins} flow={flow}></ChatBot>;
55+
};
56+
57+
export default App;

src/assets/logo.png

710 KB
Loading

src/constants/DefaultPluginConfig.ts

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,21 @@
44
export const DefaultPluginConfig = {
55
autoConfig: true, // defaults to true to help users enable required events
66
promptBaseColors: {
7-
"info": "#007bff",
8-
"warning": "#ffc107",
9-
"error": "#dc3545",
10-
"success": "#28a745",
7+
info: '#007bff',
8+
warning: '#ffc107',
9+
error: '#dc3545',
10+
success: '#28a745',
1111
},
1212
promptHoveredColors: {
13-
"info": "#0056b3",
14-
"warning": "#d39e00",
15-
"error": "#c82333",
16-
"success": "#218838",
13+
info: '#0056b3',
14+
warning: '#d39e00',
15+
error: '#c82333',
16+
success: '#218838',
1717
},
1818
textAreaHighlightColors: {
19-
"info": "#007bff",
20-
"warning": "#ffc107",
21-
"error": "#dc3545",
22-
"success": "#28a745",
23-
}
24-
}
19+
info: '#007bff',
20+
warning: '#ffc107',
21+
error: '#dc3545',
22+
success: '#28a745',
23+
},
24+
};

0 commit comments

Comments
 (0)