{
  "component": {
    "id": "formula-field",
    "name": "Formula field",
    "tier": "pro",
    "exampleId": "formula-field",
    "access": "pro",
    "requiresAuthorization": true
  },
  "source": {
    "demoModule": "src/formula-field-demo.tsx",
    "exportName": "FormulaFieldDemo",
    "sha256": "64d2021df0afbcd59e22c23423a57b023daa292d4f593b13eb2daea01ade46ec",
    "helperImports": [],
    "directComponentImports": [
      "formula-field"
    ],
    "sampleBoundary": "Existing local demo fixture with fictional data and callbacks. No live service, customer data, access key, or Pro source is included."
  },
  "install": {
    "command": "npx shadcn@latest add @tidal-pro/formula-field",
    "registryUrl": "https://tidalui.com/r/pro/formula-field.json",
    "namespace": "@tidal-pro",
    "access": "pro",
    "sourceDelivery": "server-gated",
    "requiresAuthorization": true,
    "tokenSource": "local-env",
    "tokenEnvName": "TIDALUI_TOKEN",
    "cli": {
      "package": "shadcn",
      "requested": "latest"
    }
  },
  "installPlan": [
    {
      "order": 1,
      "kind": "primary",
      "dependency": "@tidal-pro/formula-field",
      "purpose": "component",
      "command": "npx shadcn@latest add @tidal-pro/formula-field",
      "registryUrl": "https://tidalui.com/r/pro/formula-field.json",
      "access": "pro",
      "sourceDelivery": "server-gated",
      "requiresAuthorization": true
    }
  ],
  "imports": {
    "componentPath": "components/ui/formula-field.tsx",
    "exports": [
      "TidalFormulaField",
      "TidalFormulaIssue"
    ],
    "stylesheets": [
      "components/ui/tidal.css",
      "components/ui/formula-field.css"
    ],
    "scopeClass": "tidal-scope"
  },
  "dependencies": {
    "npm": [],
    "registry": [],
    "additionalRegistry": [],
    "installClosure": [
      "formula-field"
    ],
    "css": [
      "components/ui/tidal.css",
      "components/ui/formula-field.css"
    ],
    "demoCss": [],
    "consumerOwned": [
      "react",
      "react-dom"
    ]
  },
  "files": {
    "sourceFile": "/examples/formula-field.tsx",
    "demoStyles": [],
    "inlinedDemoStyles": [
      "src/formula-field-demo.css"
    ],
    "assets": []
  },
  "example": {
    "language": "tsx",
    "source": "import \"./components/ui/tidal.css\";\n\nimport { useMemo, useState, type FormEvent } from \"react\";\n\nimport { TidalFormulaField, type TidalFormulaIssue } from \"./components/ui/formula-field\";\n\nimport \"./components/ui/formula-field.css\";\n\n\n\nconst tidalExampleStyles = \".tidal-formula-demo {\\n  width: min(100%, 680px);\\n  display: grid;\\n  gap: 16px;\\n}\\n\\n.tidal-formula-demo > footer {\\n  min-width: 0;\\n  display: flex;\\n  gap: 14px;\\n  align-items: center;\\n  justify-content: space-between;\\n}\\n\\n.tidal-formula-demo > footer p {\\n  min-width: 0;\\n  margin: 0;\\n  color: var(--t-muted);\\n  font-size: 12px;\\n  line-height: 1.5;\\n  overflow-wrap: anywhere;\\n}\\n\\n.tidal-formula-demo > footer > div {\\n  display: flex;\\n  flex: 0 0 auto;\\n  gap: 8px;\\n}\\n\\n.tidal-formula-demo > footer button {\\n  min-width: 96px;\\n  min-height: 44px;\\n  padding: 8px 14px;\\n  border: 1px solid var(--t-ink);\\n  border-radius: var(--t-radius-control);\\n  background: var(--t-ink);\\n  color: var(--t-canvas);\\n  font: inherit;\\n  font-size: 12px;\\n  font-weight: 780;\\n  white-space: normal;\\n  overflow-wrap: anywhere;\\n  cursor: pointer;\\n}\\n\\n.tidal-formula-demo > footer button:first-child {\\n  border-color: var(--t-line);\\n  background: var(--t-canvas);\\n  color: var(--t-ink);\\n}\\n\\n.tidal-formula-demo > footer button:focus-visible {\\n  outline: 3px solid var(--t-accent);\\n  outline-offset: 3px;\\n}\\n\\n@media (max-width: 520px) {\\n  .tidal-formula-demo > footer {\\n    align-items: stretch;\\n    flex-direction: column;\\n  }\\n\\n  .tidal-formula-demo > footer > div {\\n    display: grid;\\n    grid-template-columns: repeat(2, minmax(0, 1fr));\\n  }\\n\\n  .tidal-formula-demo > footer button {\\n    min-width: 0;\\n  }\\n}\";\n\nconst INITIAL = \"[monthly_revenue] - [support_cost]\";\n\nconst FIELDS = [\n  {\n    id: \"monthly_revenue\",\n    label: \"Monthly revenue\",\n    token: \"[monthly_revenue]\",\n    description: \"Current-month booked revenue\",\n  },\n  {\n    id: \"support_cost\",\n    label: \"Support cost\",\n    token: \"[support_cost]\",\n    description: \"Current-month support cost\",\n  },\n  {\n    id: \"active_accounts\",\n    label: \"Active accounts\",\n    token: \"[active_accounts]\",\n    description: \"Accounts active in the selected period\",\n  },\n] as const;\n\nfunction validateFormula(value: string): readonly TidalFormulaIssue[] {\n  const opens = [...value].filter((character) => character === \"[\").length;\n  const closes = [...value].filter((character) => character === \"]\").length;\n  if (!value.trim()) return [{ id: \"required\", message: \"Enter a formula.\" }];\n  if (opens !== closes)\n    return [{ id: \"brackets\", message: \"Close each field reference with ].\" }];\n  const references = [...value.matchAll(/\\[([^\\]]+)\\]/g)].map(\n    (match) => match[1],\n  );\n  const unknown = references.find(\n    (reference) => !FIELDS.some((field) => field.id === reference),\n  );\n  return unknown\n    ? [{ id: \"unknown\", message: `Unknown field: ${unknown}.` }]\n    : [];\n}\n\nexport function FormulaFieldDemo() {\n  const [value, setValue] = useState(INITIAL);\n  const [status, setStatus] = useState(\n    \"Local sample. The formula is not evaluated or saved.\",\n  );\n  const issues = useMemo(() => validateFormula(value), [value]);\n\n  function submit(event: FormEvent<HTMLFormElement>) {\n    event.preventDefault();\n    if (issues.length) {\n      setStatus(\"Fix the formula before preparing it.\");\n      return;\n    }\n    const data = new FormData(event.currentTarget);\n    setStatus(\n      `Prepared ${String(data.get(\"workspaceFormula\"))}. Nothing was evaluated.`,\n    );\n  }\n\n  return (\n    <form\n      className=\"tidal-formula-demo\"\n      onSubmit={submit}\n      onReset={(event) => {\n        event.preventDefault();\n        setValue(INITIAL);\n        setStatus(\"Sample formula reset.\");\n      }}\n    >\n      <TidalFormulaField\n        label=\"Net monthly value\"\n        description=\"Reference workspace fields without calculating them in the browser.\"\n        name=\"workspaceFormula\"\n        value={value}\n        onValueChange={(next) => {\n          setValue(next);\n          setStatus(\n            \"Local sample updated. The formula is not evaluated or saved.\",\n          );\n        }}\n        suggestions={FIELDS}\n        issues={issues}\n        required\n        textareaProps={{ autoComplete: \"off\", spellCheck: false, rows: 4 }}\n      />\n      <footer>\n        <p aria-live=\"polite\">{status}</p>\n        <div>\n          <button type=\"reset\">Reset</button>\n          <button type=\"submit\">Prepare formula</button>\n        </div>\n      </footer>\n    </form>\n  );\n}\n\nexport default function AgentExample() {\n  return (\n    <div className=\"tidal-scope\" data-theme=\"light\" dir=\"ltr\">\n      <style>{tidalExampleStyles}</style>\n      <FormulaFieldDemo />\n    </div>\n  );\n}\n",
    "sourceFile": "/examples/formula-field.tsx",
    "fixtureData": "Existing demo fixture data only; replace with consumer-owned data before production use."
  },
  "controlledState": [
    {
      "prop": "value",
      "type": "inferred-from-existing-demo",
      "initial": "INITIAL",
      "setter": "setValue",
      "proposalCanBeRejected": false
    }
  ],
  "events": [
    {
      "name": "onReset",
      "nativeType": "React synthetic event or native callback",
      "callerFirst": true,
      "preventable": true,
      "observedResult": "The existing demo callback remains the source of truth; this example does not call a live service."
    },
    {
      "name": "onSubmit",
      "nativeType": "React synthetic event or native callback",
      "callerFirst": true,
      "preventable": true,
      "observedResult": "The existing demo callback remains the source of truth; this example does not call a live service."
    },
    {
      "name": "onValueChange",
      "nativeType": "component callback",
      "callerFirst": true,
      "preventable": true,
      "observedResult": "The existing demo callback remains the source of truth; this example does not call a live service."
    }
  ],
  "nativeForm": {
    "participates": true,
    "names": [
      "workspaceFormula"
    ],
    "expectedFormData": {
      "workspaceFormula": "fixture value"
    },
    "submitBehavior": "The existing demo's native form callback receives the submit event.",
    "resetBehavior": "Native reset behavior remains available where the demo renders a resettable control.",
    "disabledBehavior": "Disabled controls remain excluded from successful native form submission.",
    "readOnlyBehavior": "Read-only controls retain their value and remain inspectable by the consumer."
  },
  "accessibility": {
    "labelSource": "Existing demo label or ARIA prop",
    "semantics": "Preserve the component's native element and the semantics demonstrated by the source fixture.",
    "keyboard": [
      "Tab and Shift+Tab",
      "Enter or Space for native activation",
      "Arrow keys where the component exposes a composite control"
    ],
    "focusReturn": "Preserve browser focus order and visible focus.",
    "errorAnnouncement": "No error announcement path is present in this demo; the consumer owns validation messaging.",
    "reducedMotion": "Verify prefers-reduced-motion with the existing component transition path.",
    "forcedColors": "Verify visible borders, text, and focus in forced-colors mode."
  },
  "responsive": {
    "widths": [
      320,
      390,
      768,
      1260
    ],
    "shortViewport": "Check the example at a 300px viewport height with keyboard or portal content visible.",
    "overflow": "The page should not gain horizontal overflow; component-local scrolling must remain intentional.",
    "touchTargetMinPx": 44,
    "coarseInputFontPx": 16
  },
  "errors": [
    {
      "fixture": "No error fixture is exposed by the existing demo; inject a consumer-owned failure state before production use.",
      "visibleResult": "The consumer-visible result must remain explicit and must not be replaced by a silent console error.",
      "focusResult": "Focus must remain on the triggering control or move to the announced error according to the native pattern.",
      "ownership": "Consumer-owned sample state only; no network request or customer data is used."
    }
  ],
  "verification": {
    "commands": [
      "npx tsc --noEmit",
      "npx vite build"
    ],
    "lockfile": "Use the consumer project's committed lockfile.",
    "browser": [
      "Chromium 1260x800",
      "Chromium 390x844",
      "Keyboard and reduced-motion pass"
    ]
  },
  "validation": {
    "consumerFixture": {
      "tsc": "pass",
      "viteBuild": "pass",
      "resourceModel": "Generated usage plus only the component files and CSS delivered by the primary item and listed registry dependencies."
    },
    "registryArtifact": "server-gated"
  },
  "exceptions": []
}
