All files / src/pages/flowsheet-page/flowsheet/PropertiesSidebar/PropertyPanel/InputFields PropertyTextField.tsx

0% Statements 0/7
0% Branches 0/8
0% Functions 0/2
0% Lines 0/7

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50                                                                                                   
 
import DebouncedInput from "@/ahuora-design-system/ui/debounced-input";
import { Label } from "@/ahuora-design-system/ui/label";
import {
  PropertyInfoRead
} from "@/api/apiStore.gen";
 
 
 
 
 
 
 
export interface PropertyTextFieldProps {
  property: PropertyInfoRead;
  onUpdateValue: (value: string, id: number) => void;
}
 
export function PropertyTextField(props: PropertyTextFieldProps) {
  const displayName = props.property.displayName;
  const disabled = !props.property.values.enabled;
 
  const handleUpdate = (update: string | number) => {
    props.onUpdateValue(update as string, props.property.values.id);
  };
 
  const fixed = ![undefined, null, ""].includes(props.property.values.value);
 
  const value = props.property.values.value;
 
  return (
    <div className="w-full mt-1">
      {/* Container for each property */}
      {/* Text component for property name */}
      <Label color={disabled ? "disabled" : "default"}>{displayName}</Label>
      {/* Checkbox column */}
      <DebouncedInput
        onUpdate={handleUpdate}
        disabled={disabled}
        value={value}
        type="text"
        style={{ width: "100%" }}
        className={!fixed && !disabled ? "border-rose-700" : ""}
        placeholder={disabled ? "Not calculated" : "Not specified"}
        aria-label={`inputField-${displayName}`}
      />
    </div>
  );
}