Fixed copy paste on all components

This commit is contained in:
Lucas Oliveira 2023-07-20 17:17:48 -03:00
commit ab185f57bd
12 changed files with 23 additions and 77 deletions

View file

@ -152,7 +152,7 @@ export default function ParameterComponent({
return (
<div
ref={ref}
className="nopan nodrag noundo nocopy mt-1 flex w-full flex-wrap items-center justify-between bg-muted px-5 py-2"
className="mt-1 flex w-full flex-wrap items-center justify-between bg-muted px-5 py-2"
>
<>
<div
@ -242,7 +242,6 @@ export default function ParameterComponent({
) : (
<InputComponent
disabled={disabled}
disableCopyPaste={true}
password={data.node.template[name].password ?? false}
value={data.node.template[name].value ?? ""}
onChange={handleOnNewValue}
@ -264,7 +263,6 @@ export default function ParameterComponent({
<div className="mt-2 w-full">
<FloatComponent
disabled={disabled}
disableCopyPaste={true}
value={data.node.template[name].value ?? ""}
onChange={handleOnNewValue}
/>
@ -309,7 +307,6 @@ export default function ParameterComponent({
<div className="mt-2 w-full">
<IntComponent
disabled={disabled}
disableCopyPaste={true}
value={data.node.template[name].value ?? ""}
onChange={handleOnNewValue}
/>

View file

@ -51,7 +51,7 @@ export const EditFlowSettings: React.FC<InputProps> = ({
)}
</div>
<Input
className="mt-2 font-normal"
className="nopan nodrag noundo nocopy mt-2 font-normal"
onChange={handleNameChange}
type="text"
name="name"

View file

@ -1,16 +1,12 @@
import { useContext, useEffect } from "react";
import { TabsContext } from "../../contexts/tabsContext";
import { useEffect } from "react";
import { FloatComponentType } from "../../types/components";
export default function FloatComponent({
value,
onChange,
disableCopyPaste = false,
disabled,
editNode = false,
}: FloatComponentType) {
const { setDisableCopyPaste } = useContext(TabsContext);
const step = 0.1;
const min = 0;
const max = 1;
@ -25,12 +21,6 @@ export default function FloatComponent({
return (
<div className={"w-full " + (disabled ? "float-component-pointer" : "")}>
<input
onFocus={() => {
if (disableCopyPaste) setDisableCopyPaste(true);
}}
onBlur={() => {
if (disableCopyPaste) setDisableCopyPaste(false);
}}
type="number"
step={step}
min={min}
@ -45,9 +35,10 @@ export default function FloatComponent({
max={max}
value={value ?? ""}
className={
editNode
"nopan nodrag noundo nocopy " +
(editNode
? "input-edit-node"
: "input-primary" + (disabled ? " input-disable " : "")
: "input-primary" + (disabled ? " input-disable " : ""))
}
placeholder={
editNode ? "Number 0 to 1" : "Type a number from zero to one"

View file

@ -1,18 +1,15 @@
import { useContext, useEffect, useState } from "react";
import { TabsContext } from "../../contexts/tabsContext";
import { useEffect, useState } from "react";
import { InputComponentType } from "../../types/components";
import { classNames } from "../../utils/utils";
export default function InputComponent({
value,
onChange,
disableCopyPaste = false,
disabled,
password,
editNode = false,
}: InputComponentType) {
const [pwdVisible, setPwdVisible] = useState(false);
const { setDisableCopyPaste } = useContext(TabsContext);
// Clear component state
useEffect(() => {
@ -25,18 +22,13 @@ export default function InputComponent({
<div className={disabled ? "input-component-div" : "relative"}>
<input
value={value}
onFocus={() => {
if (disableCopyPaste) setDisableCopyPaste(true);
}}
onBlur={() => {
if (disableCopyPaste) setDisableCopyPaste(false);
}}
className={classNames(
disabled ? " input-disable " : "",
password && !pwdVisible && value !== "" ? " text-clip password " : "",
editNode ? " input-edit-node " : " input-primary ",
password && editNode ? "pr-8" : "",
password && !editNode ? "pr-10" : ""
password && !editNode ? "pr-10" : "",
"nopan nodrag noundo nocopy"
)}
placeholder={password && editNode ? "Key" : "Type something..."}
onChange={(e) => {

View file

@ -40,9 +40,10 @@ export default function InputListComponent({
type="text"
value={i}
className={
editNode
"nopan nodrag noundo nocopy " +
(editNode
? "input-edit-node "
: "input-primary " + (disabled ? "input-disable" : "")
: "input-primary " + (disabled ? "input-disable" : ""))
}
placeholder="Type something..."
onChange={(e) => {

View file

@ -1,15 +1,12 @@
import { useContext, useEffect } from "react";
import { TabsContext } from "../../contexts/tabsContext";
import { useEffect } from "react";
import { FloatComponentType } from "../../types/components";
export default function IntComponent({
value,
onChange,
disableCopyPaste = false,
disabled,
editNode = false,
}: FloatComponentType) {
const { setDisableCopyPaste } = useContext(TabsContext);
const min = 0;
// Clear component state
@ -27,12 +24,6 @@ export default function IntComponent({
}
>
<input
onFocus={() => {
if (disableCopyPaste) setDisableCopyPaste(true);
}}
onBlur={() => {
if (disableCopyPaste) setDisableCopyPaste(false);
}}
onKeyDown={(event) => {
if (
event.key !== "Backspace" &&
@ -61,9 +52,10 @@ export default function IntComponent({
}}
value={value ?? ""}
className={
editNode
"nopan nodrag noundo nocopy " +
(editNode
? " input-edit-node "
: " input-primary " + (disabled ? " input-disable" : "")
: " input-primary " + (disabled ? " input-disable" : ""))
}
placeholder={editNode ? "Integer number" : "Type an integer number"}
onChange={(e) => {

View file

@ -1,6 +1,5 @@
import { useContext, useEffect } from "react";
import { useEffect } from "react";
import { TypeModal } from "../../constants/enums";
import { TabsContext } from "../../contexts/tabsContext";
import GenericModal from "../../modals/genericModal";
import { TextAreaComponentType } from "../../types/components";
import IconComponent from "../genericIconComponent";
@ -11,8 +10,6 @@ export default function TextAreaComponent({
disabled,
editNode = false,
}: TextAreaComponentType) {
const { setDisableCopyPaste } = useContext(TabsContext);
// Clear text area
useEffect(() => {
if (disabled) {
@ -25,17 +22,11 @@ export default function TextAreaComponent({
<div className="flex w-full items-center">
<input
value={value}
onFocus={() => {
setDisableCopyPaste(true);
}}
onBlur={() => {
setDisableCopyPaste(false);
}}
className={
(editNode
? " input-edit-node "
: " input-primary " + (disabled ? " input-disable" : "")) +
" w-full"
" nopan nodrag noundo nocopy w-full"
}
placeholder={"Type something..."}
onChange={(e) => {

View file

@ -10,7 +10,7 @@ const Input = React.forwardRef<HTMLInputElement, InputProps>(
<input
type={type}
className={cn(
"flex h-10 w-full rounded-md border border-input bg-transparent px-3 py-2 text-sm ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",
"nopan nodrag noundo nocopy flex h-10 w-full rounded-md border border-input bg-transparent px-3 py-2 text-sm ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",
className
)}
ref={ref}

View file

@ -57,7 +57,7 @@ export default function RenameLabel(props) {
ref={inputRef}
onInput={resizeInput}
className={cn(
"rounded-md bg-transparent px-2 outline-ring hover:outline focus:border-none focus:outline active:outline",
"nopan nodrag noundo nocopy rounded-md bg-transparent px-2 outline-ring hover:outline focus:border-none focus:outline active:outline",
props.className
)}
onBlur={() => {

View file

@ -1,4 +1,4 @@
import { ReactNode, useContext, useEffect, useState } from "react";
import { ReactNode } from "react";
import React from "react";
import {
@ -9,7 +9,6 @@ import {
DialogTitle,
DialogTrigger,
} from "../../components/ui/dialog";
import { TabsContext } from "../../contexts/tabsContext";
type ContentProps = { children: ReactNode };
type HeaderProps = { children: ReactNode; description: string };
@ -97,24 +96,9 @@ function BaseModal({
break;
}
const { disableCopyPaste, setDisableCopyPaste } = useContext(TabsContext);
const [keepDisabling, setKeepDisabling] = useState(false);
useEffect(() => {
if (keepDisabling) {
setDisableCopyPaste(true);
}
}, [disableCopyPaste]);
useEffect(() => {
if (!open) {
setKeepDisabling(false);
}
}, [open]);
//UPDATE COLORS AND STYLE CLASSSES
return (
<Dialog modal={true} open={open} onOpenChange={setOpen}>
<Dialog open={open} onOpenChange={setOpen}>
<DialogTrigger className="w-full" hidden={triggerChild ? false : true}>
{triggerChild}
</DialogTrigger>

View file

@ -114,7 +114,7 @@ export default function ExtraSidebar() {
name="search"
id="search"
placeholder="Search"
className="input-search"
className="nopan nodrag noundo nocopy input-search"
onChange={(e) => {
handleSearchInput(e.target.value);
// Set search input state

View file

@ -7,7 +7,6 @@ export type InputComponentType = {
disabled?: boolean;
onChange: (value: string) => void;
password: boolean;
disableCopyPaste?: boolean;
editNode?: boolean;
onChangePass?: (value: boolean | boolean) => void;
showPass?: boolean;
@ -94,7 +93,6 @@ export type DisclosureComponentType = {
export type FloatComponentType = {
value: string;
disabled?: boolean;
disableCopyPaste?: boolean;
onChange: (value: string) => void;
editNode?: boolean;
};