{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "additionalProperties": false,
  "description": "The grid block (data). Reads: the rows of `source` (up to 1,000), searched, filtered, sorted and paged by the address's query. Shape: one row per line with an `id` (integer, or text hashed to the row id) and every column `columns` names.",
  "properties": {
    "grid": {
      "additionalProperties": false,
      "properties": {
        "actions": {
          "description": "Bulk actions on the selected rows: `- set: {…}`, `- delete: {…}`, `- export: csv`.",
          "items": {
            "oneOf": [
              {
                "additionalProperties": false,
                "description": "sets the column to the value on those rows",
                "properties": {
                  "set": {
                    "additionalProperties": false,
                    "properties": {
                      "approval": {
                        "default": false,
                        "description": "Through the confirm page first.",
                        "type": "boolean"
                      },
                      "column": {
                        "description": "The column it sets.",
                        "pattern": "^[a-z][a-z0-9_]{0,62}$",
                        "type": "string"
                      },
                      "id": {
                        "description": "The action's id; default `set-<column>`, plus `-<value>` when a value is given.",
                        "pattern": "^[a-z][a-z0-9-]{1,38}$",
                        "type": "string"
                      },
                      "label": {
                        "description": "The button's words.",
                        "maxLength": 40,
                        "minLength": 1,
                        "type": "string"
                      },
                      "options": {
                        "description": "The values the person picks from; or `value`.",
                        "items": {
                          "type": [
                            "string",
                            "number",
                            "boolean",
                            "null"
                          ]
                        },
                        "maxItems": 30,
                        "minItems": 1,
                        "type": "array"
                      },
                      "value": {
                        "description": "The value it sets; or `options`.",
                        "type": [
                          "string",
                          "number",
                          "boolean",
                          "null"
                        ]
                      }
                    },
                    "required": [
                      "column",
                      "label"
                    ],
                    "type": "object"
                  }
                },
                "required": [
                  "set"
                ],
                "type": "object"
              },
              {
                "additionalProperties": false,
                "description": "deletes those rows",
                "properties": {
                  "delete": {
                    "additionalProperties": false,
                    "properties": {
                      "id": {
                        "description": "The action's id; default `delete`.",
                        "pattern": "^[a-z][a-z0-9-]{1,38}$",
                        "type": "string"
                      },
                      "label": {
                        "default": "Delete",
                        "description": "The button's words.",
                        "maxLength": 40,
                        "minLength": 1,
                        "type": "string"
                      }
                    },
                    "type": "object"
                  }
                },
                "required": [
                  "delete"
                ],
                "type": "object"
              },
              {
                "additionalProperties": false,
                "description": "downloads the grid's current view as CSV (RFC 4180: CRLF after each record); written `- export: csv`",
                "properties": {
                  "export": {
                    "enum": [
                      "csv"
                    ]
                  }
                },
                "required": [
                  "export"
                ],
                "type": "object"
              }
            ]
          },
          "type": "array"
        },
        "columns": {
          "description": "The columns, in order.",
          "items": {
            "additionalProperties": false,
            "properties": {
              "key": {
                "description": "The source column the cell shows.",
                "pattern": "^[a-z][a-z0-9_]{0,62}$",
                "type": "string"
              },
              "kind": {
                "default": "text",
                "description": "How the cell draws its value; numeric kinds align themselves.",
                "enum": [
                  "text",
                  "strong",
                  "muted",
                  "mono",
                  "number",
                  "status",
                  "badge",
                  "time",
                  "bar"
                ],
                "type": "string"
              },
              "label": {
                "description": "The column's heading.",
                "maxLength": 60,
                "minLength": 1,
                "type": "string"
              },
              "max": {
                "description": "The value of a full bar (bar cells only).",
                "type": "number"
              },
              "priority": {
                "default": "primary",
                "description": "primary never hides; secondary hides below 1060 px, tertiary below 720 px.",
                "enum": [
                  "primary",
                  "secondary",
                  "tertiary"
                ],
                "type": "string"
              },
              "tones": {
                "additionalProperties": {
                  "enum": [
                    "neutral",
                    "ok",
                    "warn",
                    "bad",
                    "info"
                  ],
                  "type": "string"
                },
                "description": "Cell value → tone, for status and badge cells.",
                "type": "object"
              }
            },
            "required": [
              "key",
              "label"
            ],
            "type": "object"
          },
          "maxItems": 30,
          "minItems": 1,
          "type": "array"
        },
        "filters": {
          "default": [],
          "description": "The columns a person can filter by (keys of `columns`).",
          "items": {
            "pattern": "^[a-z][a-z0-9_]{0,62}$",
            "type": "string"
          },
          "maxItems": 30,
          "minItems": 0,
          "type": "array"
        },
        "id": {
          "description": "The block's id: its Markdown anchor and its actions' route (`/act/<id>/<action>`). Default `<type>-<n>`, n counting blocks of this type depth-first from 1.",
          "pattern": "^[a-z][a-z0-9-]{1,38}$",
          "type": "string"
        },
        "open": {
          "description": "The screen a row opens: its first column links to `/a/<app>/<open>?id=<row id>`; `$id` opens the screen the row's id names, `/a/<app>/<row id>`.",
          "pattern": "^([a-z][a-z0-9-]{1,38}|\\$id)$",
          "type": "string"
        },
        "page_size": {
          "default": 25,
          "description": "Rows per page.",
          "enum": [
            25,
            50,
            100
          ],
          "type": "integer"
        },
        "plain": {
          "default": false,
          "description": "No toolbar, no selection, no pager (a small read-only table).",
          "type": "boolean"
        },
        "search": {
          "default": true,
          "description": "A search box over every visible column.",
          "type": "boolean"
        },
        "source": {
          "description": "The source whose rows it shows.",
          "pattern": "^[a-z][a-z0-9_]{0,62}$",
          "type": "string"
        }
      },
      "required": [
        "source",
        "columns"
      ],
      "type": "object"
    }
  },
  "required": [
    "grid"
  ],
  "title": "grid",
  "type": "object"
}