MCPcopy Create free account
hub / github.com/UsefulSoftwareCo/executor / ConstField

Function ConstField

packages/react/src/components/json-schema-form.tsx:559–578  ·  view source on GitHub ↗
(props: {
  readonly fieldId: string;
  readonly constValue: unknown;
  readonly value: unknown;
  readonly onChange: (next: unknown) => void;
})

Source from the content-addressed store, hash-verified

557// ---------------------------------------------------------------------------
558
559function ConstField(props: {
560 readonly fieldId: string;
561 readonly constValue: unknown;
562 readonly value: unknown;
563 readonly onChange: (next: unknown) => void;
564}): React.ReactElement {
565 const { fieldId, constValue, value, onChange } = props;
566 useEffect(() => {
567 if (value !== constValue) onChange(constValue);
568 }, [value, constValue, onChange]);
569 return (
570 <Input
571 id={fieldId}
572 className="text-xs"
573 value={safeSchemaValueLabel(constValue)}
574 disabled
575 readOnly
576 />
577 );
578}
579
580// ---------------------------------------------------------------------------
581// NumberField — keeps a local draft so transient/invalid text doesn't clobber

Callers

nothing calls this directly

Calls 2

safeSchemaValueLabelFunction · 0.90
onChangeFunction · 0.50

Tested by

no test coverage detected