{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "textarea",
  "title": "Textarea",
  "description": "A labelled multi-line input with a character count.",
  "dependencies": [
    "@ui-sdk/react@0.1.0-beta.5"
  ],
  "registryDependencies": [
    "https://www.cyberspec.dev/r/cyber.json"
  ],
  "files": [
    {
      "path": "registry/cyber/ui/textarea.tsx",
      "content": "\"use client\"\n\nimport * as React from \"react\"\nimport { Field, FieldDescription, FieldError, FieldLabel } from \"@ui-sdk/react/field\"\nimport { Textarea as SdkTextarea } from \"@ui-sdk/react/textarea\"\nimport \"@/registry/cyber/ui/cyber/textarea.css\"\n\n// Several lines of text in the kit's field box. It grows with what's typed\n// until it reaches its tallest, then scrolls.\n//\n// With `maxLength`, a readout beside the label counts the characters used.\n// It turns to the flag color over the last tenth, and prints MAX at the\n// limit. A screen reader hears the count when focus arrives, and is told\n// once when the text is nearly full and once when it's full, not on every\n// key.\n//\n// - `hint` describes the field; `error` marks it invalid with a message.\n// - `rows` is its shortest, three lines by default. `autoResize` is on;\n//   pass `autoResize={false}` for a fixed box with a drag handle.\n//\n// Everything else goes to the textarea: `value`, `onValueChange`, `rows`,\n// `submitShortcut`, a `controller`.\nfunction Textarea({\n  label,\n  hint,\n  error,\n  disabled,\n  maxLength,\n  value,\n  defaultValue,\n  onValueChange,\n  autoResize = true,\n  rows = 3,\n  ...props\n}: React.ComponentProps<typeof SdkTextarea> & {\n  label: string\n  hint?: React.ReactNode\n  error?: string\n}) {\n  // The count has to follow typing, a reset, a controller and an agent\n  // alike, so it's kept from the change callback, which hears all four.\n  // It describes the textarea through aria-describedby, which the field\n  // merges with its own: a field keeps only one FieldDescription, and that\n  // one is the hint.\n  const [typed, setTyped] = React.useState(() => (defaultValue ?? \"\").length)\n  const used = value != null ? value.length : typed\n  const countId = React.useId()\n\n  const left = maxLength != null ? Math.max(0, maxLength - used) : null\n  const nearAt = maxLength != null ? Math.max(1, Math.round(maxLength / 10)) : 0\n  const full = left === 0\n  const near = left != null && left <= nearAt\n\n  return (\n    <Field data-kit=\"field\" disabled={disabled} invalid={error ? true : undefined}>\n      <div data-kit=\"textarea-head\">\n        <FieldLabel data-kit=\"label\">{label}</FieldLabel>\n        {maxLength != null && (\n          <span id={countId} data-kit=\"textarea-count\" data-near={near ? \"\" : undefined} data-full={full ? \"\" : undefined}>\n            {full && (\n              <span data-kit=\"textarea-tag\" aria-hidden>\n                MAX\n              </span>\n            )}\n            <span aria-hidden>\n              {String(used).padStart(String(maxLength).length, \"0\")}/{maxLength}\n            </span>\n            <span data-sr-only>\n              {used} of {maxLength} characters used\n            </span>\n          </span>\n        )}\n      </div>\n      <div data-kit=\"control\" data-frame=\"br\" data-frame-focus=\"within\">\n        <span data-kit=\"textarea-tick\" aria-hidden />\n        <SdkTextarea\n          data-kit=\"textarea\"\n          data-grow={autoResize ? \"\" : undefined}\n          autoResize={autoResize}\n          rows={rows}\n          style={{ \"--rows\": rows } as React.CSSProperties}\n          maxLength={maxLength}\n          aria-describedby={maxLength != null ? countId : undefined}\n          value={value}\n          defaultValue={defaultValue}\n          onValueChange={(next, details) => {\n            onValueChange?.(next, details)\n            if (!details.canceled) setTyped(next.length)\n          }}\n          {...props}\n        />\n      </div>\n      {maxLength != null && (\n        <span data-sr-only role=\"status\">\n          {full ? \"Character limit reached.\" : near ? `${nearAt} characters or fewer left.` : \"\"}\n        </span>\n      )}\n      {hint && <FieldDescription data-kit=\"hint\">{hint}</FieldDescription>}\n      {error ? (\n        <FieldError data-kit=\"field-error\" match>\n          {error}\n        </FieldError>\n      ) : (\n        <FieldError data-kit=\"field-error\" />\n      )}\n    </Field>\n  )\n}\n\nexport { Textarea }\n",
      "type": "registry:ui",
      "target": "@ui/textarea.tsx"
    },
    {
      "path": "registry/cyber/ui/cyber/textarea.css",
      "content": "@layer ui-sdk, cyber.tokens, cyber.base, cyber.ui, cyber.blocks, cyber.fx, cyber.a11y;\n\n/* A textarea is the shared field box (field.css), taller, with a count\n   readout in its label's row and the same lit tick a text field has. */\n@layer cyber.ui {\n  [data-skin=\"cyber\"] [data-kit=\"textarea-head\"] {\n    display: flex;\n    align-items: baseline;\n    justify-content: space-between;\n    gap: 12px;\n    min-width: 0;\n\n    &:has([data-disabled]) [data-kit=\"label\"] {\n      color: var(--cy-ink-mute);\n    }\n  }\n\n  /* Characters used, zero-padded so the readout never changes width as it\n     counts. A value, so it's the signal color; over the last tenth it's the\n     flag color, and at the limit it says so in a word as well. */\n  [data-skin=\"cyber\"] [data-kit=\"textarea-count\"] {\n    flex: none;\n    display: flex;\n    align-items: center;\n    gap: 6px;\n    font-family: var(--cy-mono);\n    font-size: var(--cy-text-xs);\n    line-height: 1;\n    font-variant-numeric: tabular-nums;\n    color: var(--cy-signal);\n    transition: color var(--cy-t-fast) linear;\n\n    &[data-near] {\n      color: var(--cy-flag);\n    }\n\n    [data-kit=\"textarea-head\"]:has([data-disabled]) > & {\n      color: var(--cy-ink-mute);\n    }\n  }\n\n  [data-skin=\"cyber\"] [data-kit=\"textarea-tag\"] {\n    padding: 2px 4px 1px;\n    font-weight: 700;\n    letter-spacing: 0.06em;\n    color: var(--cy-on-solid);\n    background: var(--cy-flag);\n    animation: var(--cy-fx-in) 200ms var(--cy-ease-snap) backwards;\n  }\n\n  /* Named with its element so these win over the shared box's own textarea\n     rules (field.css), whichever stylesheet loads first. */\n  [data-skin=\"cyber\"] [data-kit=\"control\"] textarea[data-kit=\"textarea\"] {\n    min-height: calc(1.4em * var(--rows, 3) + 16px);\n    max-height: calc(1.4em * 9 + 16px);\n    overflow-y: auto;\n    overscroll-behavior: contain;\n    text-wrap: pretty;\n\n    /* The box shows focus for the textarea (data-frame-focus=\"within\"), so\n       the textarea's own ring is cut off rather than drawn twice. */\n    clip-path: inset(0);\n\n    /* A fixed box can be dragged taller; one that sizes itself can't, so it\n       shows no grip. */\n    &[data-grow] {\n      resize: none;\n    }\n  }\n\n  /* A segment of the leading edge: the signal color once the field holds\n     something, the flag color when what it holds is wrong. */\n  [data-skin=\"cyber\"] [data-kit=\"textarea-tick\"] {\n    position: absolute;\n    inset-block: 9px auto;\n    inset-inline-start: -1px;\n    width: 3px;\n    height: 18px;\n    background: transparent;\n    pointer-events: none;\n    transition: background-color var(--cy-t) var(--cy-ease-snap);\n\n    [data-kit=\"control\"]:has([data-filled]) > & {\n      background: var(--cy-signal);\n    }\n    [data-kit=\"control\"]:has([aria-invalid=\"true\"]) > & {\n      background: var(--cy-flag);\n    }\n    [data-kit=\"control\"]:has([data-disabled]) > & {\n      background: transparent;\n    }\n  }\n}\n",
      "type": "registry:file",
      "target": "@ui/cyber/textarea.css"
    }
  ],
  "type": "registry:ui"
}
