{
  "$schema": "https://design.senvenli.com/schema/component.full.json",
  "kind": "component",
  "family": "form",
  "status": "alpha",
  "import": "@senvenli/react/form",
  "name": "image-cropper",
  "title": "Image cropper",
  "exports": [
    "ImageCropper"
  ],
  "description": "Frames one picked image to the shape a surface needs: pan, zoom, rotate, an aspect preset, and the output as a file.",
  "keywords": [
    "crop",
    "image",
    "upload",
    "avatar",
    "logo"
  ],
  "usage": {
    "when": [
      "Before an uploaded image is saved: a cover photo, an avatar, a logo."
    ],
    "instead": [
      {
        "use": "file-upload",
        "when": "Files are kept as picked, without framing."
      },
      {
        "use": "image",
        "when": "The picture is only shown."
      }
    ]
  },
  "a11y": {
    "keyboard": [
      {
        "keys": "Arrow keys",
        "does": "Move the image in the frame."
      },
      {
        "keys": "+ / -",
        "does": "Zoom in or out."
      }
    ],
    "builtIn": [
      "The frame announces its position and zoom."
    ],
    "youProvide": [
      "What is being cropped, as its name."
    ]
  },
  "related": [
    "file-upload"
  ],
  "genui": {
    "expose": false
  },
  "source": [
    "src/form/image-cropper.tsx"
  ],
  "props": {
    "ImageCropper": [
      {
        "name": "src",
        "type": "string | Blob",
        "required": true,
        "origin": "own",
        "description": "The picked file (from FileTrigger, already checked for size and type), or an image URL. A URL from\nanother origin is loaded with CORS so the crop can be read back: its server must send\n`Access-Control-Allow-Origin`, or the image does not open (rather than failing later at save)."
      },
      {
        "name": "label",
        "type": "string",
        "required": true,
        "origin": "own",
        "description": "What is being cropped (\"Cover photo\"); names the crop frame.",
        "schema": {
          "type": "string"
        }
      },
      {
        "name": "aspectRatio",
        "type": "ImageCropperAspect",
        "required": false,
        "origin": "own",
        "default": "16 / 9",
        "description": "16:9 by default; `\"free\"` keeps the image's own shape. Ignored when presets are given."
      },
      {
        "name": "aspectPresets",
        "type": "readonly ImageCropperPreset[]",
        "required": false,
        "origin": "own",
        "description": "Two or more shapes to choose from (a segmented control); the first is selected."
      },
      {
        "name": "fit",
        "type": "CropFit",
        "required": false,
        "origin": "own",
        "default": "\"cover\"",
        "description": "`cover` (default) fills the frame; `contain` fits the whole image and leaves empty area.",
        "schema": {
          "type": "string",
          "enum": [
            "cover",
            "contain"
          ]
        }
      },
      {
        "name": "background",
        "type": "string",
        "required": false,
        "origin": "own",
        "default": "\"#ffffff\"",
        "description": "The empty area's colour in `contain` when the output has no alpha (JPEG). White by default.",
        "schema": {
          "type": "string"
        }
      },
      {
        "name": "outputType",
        "type": "CropOutputType",
        "required": false,
        "origin": "own",
        "default": "\"image/jpeg\"",
        "description": "`image/jpeg` by default. PNG and WebP keep transparency.",
        "schema": {
          "type": "string",
          "enum": [
            "image/jpeg",
            "image/png",
            "image/webp"
          ]
        }
      },
      {
        "name": "quality",
        "type": "number",
        "required": false,
        "origin": "own",
        "default": "0.9",
        "description": "0–1, for JPEG and WebP. 0.9 by default.",
        "schema": {
          "type": "number"
        }
      },
      {
        "name": "maxBytes",
        "type": "number",
        "required": false,
        "origin": "own",
        "description": "The largest file the surface takes, in bytes. A JPEG or WebP\nover it is encoded again at a quality 0.1 lower each time, down to `minimumQuality`; when even that is over, or\na PNG is, nothing is handed to `onCrop` and the cropper says the image is over the limit (a smaller crop, by\nzooming in, or another image fits).",
        "schema": {
          "type": "number"
        }
      },
      {
        "name": "minimumQuality",
        "type": "number",
        "required": false,
        "origin": "own",
        "description": "The lowest quality `maxBytes` may step down to (0.9 keeps a hero or slide sharp). 0.1 by default; at most `quality`.",
        "schema": {
          "type": "number"
        }
      },
      {
        "name": "maxOutputSize",
        "type": "number",
        "required": false,
        "origin": "own",
        "default": "4096",
        "description": "The output's long edge in px at most (a surface's size, 2560 for a full-width photo): larger crops scale down,\nnever up. 4096 by default, so a 48 MP phone photo stays within every browser's canvas limit.",
        "schema": {
          "type": "number"
        }
      },
      {
        "name": "minOutputSize",
        "type": "number",
        "required": false,
        "origin": "own",
        "description": "Under this long edge the warning shows; it never blocks.",
        "schema": {
          "type": "number"
        }
      },
      {
        "name": "fileName",
        "type": "string",
        "required": false,
        "origin": "own",
        "description": "The output file's name without extension; the source file's name by default.",
        "schema": {
          "type": "string"
        }
      },
      {
        "name": "onCrop",
        "type": "(file: File, result: ImageCropperResult) => unknown",
        "required": true,
        "origin": "own"
      },
      {
        "name": "onCancel",
        "type": "() => void",
        "required": false,
        "origin": "own"
      }
    ]
  },
  "tokens": [
    "ds-background-brand-bold",
    "ds-background-disabled",
    "ds-background-neutral",
    "ds-background-selected",
    "ds-blanket",
    "ds-border",
    "ds-border-bold",
    "ds-border-focused",
    "ds-border-selected",
    "ds-link",
    "ds-radius-full",
    "ds-radius-large",
    "ds-radius-medium",
    "ds-shadow-raised",
    "ds-space-050",
    "ds-space-100",
    "ds-space-150",
    "ds-space-300",
    "ds-space-400",
    "ds-surface-raised",
    "ds-surface-sunken",
    "ds-text",
    "ds-text-danger",
    "ds-text-disabled",
    "ds-text-subtle",
    "ds-text-subtlest",
    "ds-text-warning"
  ],
  "strings": [
    "cancel",
    "cancelUpload",
    "chooseFiles",
    "colorBlack",
    "colorLightGrey",
    "colorWhite",
    "cropAspect",
    "cropBackground",
    "cropCentered",
    "cropContain",
    "cropCover",
    "cropFit",
    "cropHelp",
    "cropKeepsAlpha",
    "cropLoadFailed",
    "cropOutput",
    "cropPosition",
    "cropRotateLeft",
    "cropRotateRight",
    "cropSave",
    "cropSaveFailed",
    "cropSmall",
    "cropStatus",
    "cropTooLarge",
    "cropZoom",
    "cropZoomIn",
    "cropZoomOut",
    "customColor",
    "hexExpected",
    "nameSelected",
    "newTab",
    "onlyOne",
    "optional",
    "removeFile",
    "replace",
    "required",
    "tooLarge",
    "upTo",
    "uploaded",
    "wrongType"
  ],
  "quality": {
    "tests": true,
    "a11y": false,
    "docs": false,
    "visual": false,
    "dark": false,
    "rtl": false,
    "mcp": true,
    "generic": true
  }
}
