Skip to content

Open-source manufacturing ERP, MES and QMS. Quoting, MRP, inventory, shop floor, quality and lot/serial traceability on one Postgres schema, with a REST API and MCP server. Self-host or use Carbon Cloud.

1.4 KB
Raw Blame
// SPDX-License-Identifier: AGPL-3.0-only
// Carbon (github.com/crbnos/carbon). Modified or adapted versions of this file,
// including ports, remain AGPLv3; serving them over a network requires releasing their source.

import { Field } from "./Field";
import { InlineValueEditor } from "./InlineValueEditor";
import type { ValueFieldProps } from "./types";

/** A field that always mixes text and variables. Accepts any type that has a reading
 * as text — a whole record does not, so the menu offers its properties instead. */
export function TemplateField({
  label,
  required,
  helpTermId,
  help,
  hint,
  value,
  onChange,
  context,
  issue,
  partIssues,
  isReadOnly
}: ValueFieldProps) {
  return (
    <Field
      label={label}
      required={required}
      helpTermId={helpTermId}
      help={help}
      issue={issue}
      hint={hint}
    >
      {/* These are the prose inputs — a subject, a message body, a webhook payload.
          They open at a few rows and take line breaks, so a JSON payload can be
          written the way it is read. */}
      <InlineValueEditor
        textOnly
        collapseSingleRef={false}
        value={value}
        onChange={onChange}
        context={context}
        hasIssue={!!issue}
        partIssues={partIssues}
        multiline
        minRows={4}
        maxRows={12}
        isReadOnly={isReadOnly}
      />
    </Field>
  );
}