moved some constants to constant file

This commit is contained in:
anovazzi1 2023-07-13 19:45:04 -03:00
commit 62dde544c1
3 changed files with 37 additions and 32 deletions

View file

@ -1,6 +1,7 @@
// src/constants.tsx // src/constants.tsx
import { MessageSquare } from "lucide-react"; import { MessageSquare } from "lucide-react";
import { IVarHighlightType } from "./types/components";
import { FlowType } from "./types/flow"; import { FlowType } from "./types/flow";
import { TabsState } from "./types/tabs"; import { TabsState } from "./types/tabs";
import { buildInputs } from "./utils"; import { buildInputs } from "./utils";
@ -13,6 +14,38 @@ import { buildTweaks } from "./utils/reactflowUtils";
interface languageMap { interface languageMap {
[key: string]: string | undefined; [key: string]: string | undefined;
} }
/**
* invalid characters for flow name
* @constant
*/
export const INVALID_CHARACTERS = [
" ",
",",
".",
":",
";",
"!",
"?",
"/",
"\\",
"(",
")",
"[",
"]",
"\n",
];
/**
* regex to highlight the variables in the text
* @constant
*/
export const regexHighlight = /\{([^}]+)\}/g;
export const varHighlightHTML = ({ name }: IVarHighlightType) => {
const html = `<span class="font-semibold chat-message-highlight">{${name}}</span>`;
return html;
};
export const programmingLanguages: languageMap = { export const programmingLanguages: languageMap = {
javascript: ".js", javascript: ".js",

View file

@ -7,23 +7,20 @@ import { Button } from "../../components/ui/button";
import { DialogTitle } from "../../components/ui/dialog"; import { DialogTitle } from "../../components/ui/dialog";
import { Textarea } from "../../components/ui/textarea"; import { Textarea } from "../../components/ui/textarea";
import { import {
INVALID_CHARACTERS,
MAX_WORDS_HIGHLIGHT, MAX_WORDS_HIGHLIGHT,
PROMPT_DIALOG_SUBTITLE, PROMPT_DIALOG_SUBTITLE,
TEXT_DIALOG_SUBTITLE, TEXT_DIALOG_SUBTITLE,
TypeModal, TypeModal,
regexHighlight,
varHighlightHTML,
} from "../../constants"; } from "../../constants";
import { alertContext } from "../../contexts/alertContext"; import { alertContext } from "../../contexts/alertContext";
import { darkContext } from "../../contexts/darkContext"; import { darkContext } from "../../contexts/darkContext";
import { PopUpContext } from "../../contexts/popUpContext"; import { PopUpContext } from "../../contexts/popUpContext";
import { postValidatePrompt } from "../../controllers/API"; import { postValidatePrompt } from "../../controllers/API";
import { APIClassType } from "../../types/api"; import { APIClassType } from "../../types/api";
import { import { classNames, getRandomKeyByssmm } from "../../utils";
INVALID_CHARACTERS,
classNames,
getRandomKeyByssmm,
regexHighlight,
varHighlightHTML,
} from "../../utils";
import BaseModal from "../baseModal"; import BaseModal from "../baseModal";
export default function GenericModal({ export default function GenericModal({

View file

@ -1,7 +1,6 @@
import clsx, { ClassValue } from "clsx"; import clsx, { ClassValue } from "clsx";
import { twMerge } from "tailwind-merge"; import { twMerge } from "tailwind-merge";
import { ADJECTIVES, DESCRIPTIONS, NOUNS } from "./flow_constants"; import { ADJECTIVES, DESCRIPTIONS, NOUNS } from "./flow_constants";
import { IVarHighlightType } from "./types/components";
export function classNames(...classes: Array<string>) { export function classNames(...classes: Array<string>) {
return classes.filter(Boolean).join(" "); return classes.filter(Boolean).join(" ");
@ -252,27 +251,3 @@ export function getRandomKeyByssmm(): string {
const milliseconds = String(now.getMilliseconds()).padStart(3, "0"); const milliseconds = String(now.getMilliseconds()).padStart(3, "0");
return seconds + milliseconds + Math.abs(Math.floor(Math.random() * 10001)); return seconds + milliseconds + Math.abs(Math.floor(Math.random() * 10001));
} }
export const INVALID_CHARACTERS = [
" ",
",",
".",
":",
";",
"!",
"?",
"/",
"\\",
"(",
")",
"[",
"]",
"\n",
];
export const regexHighlight = /\{([^}]+)\}/g;
export const varHighlightHTML = ({ name }: IVarHighlightType) => {
const html = `<span class="font-semibold chat-message-highlight">{${name}}</span>`;
return html;
};