{
  "$schema": "https://next.0build.dev/schema/component.v1.json",
  "accessibility": {
    "aria": [],
    "notes": [
      "Handles are kept button-accessible; keyboard grabbing moves items with live position feedback and restores focus after drops.",
      "Interactive content inside items (inputs, buttons, links, editable regions) never starts a drag."
    ]
  },
  "attributes": [
    {
      "default": "''",
      "description": "Selector of the sortable container inside the host. Defaults to `[data-sortable-target]`, a single `ul`/`ol`/`table` child (tables use their first `tbody`), or the host itself.",
      "from": null,
      "name": "target",
      "property": "target",
      "reflect": false,
      "tokens": null,
      "type": "string",
      "values": null
    },
    {
      "default": "''",
      "description": "Shared group name; items can be dragged between sortables with the same non-empty group.",
      "from": null,
      "name": "group",
      "property": "group",
      "reflect": false,
      "tokens": null,
      "type": "string",
      "values": null
    },
    {
      "default": "''",
      "description": "Selector for drag handles inside each item. Defaults to `[data-sortable-handle]`; with no handles the whole item is draggable.",
      "from": null,
      "name": "handle",
      "property": "handle",
      "reflect": false,
      "tokens": null,
      "type": "string",
      "values": null
    },
    {
      "default": "5",
      "description": "Pointer movement in pixels before a drag starts (default 5), so clicks on items still work.",
      "from": null,
      "name": "threshold",
      "property": "threshold",
      "reflect": false,
      "tokens": null,
      "type": "number",
      "values": null
    },
    {
      "default": "150",
      "description": "Move animation duration in milliseconds (default 150).",
      "from": null,
      "name": "duration",
      "property": "duration",
      "reflect": false,
      "tokens": null,
      "type": "number",
      "values": null
    },
    {
      "default": "false",
      "description": "Disables move animations.",
      "from": null,
      "name": "no-animation",
      "property": "no-animation",
      "reflect": false,
      "tokens": null,
      "type": "boolean",
      "values": null
    },
    {
      "default": "false",
      "description": "Disables dragging and keyboard grabbing; cancels any active session.",
      "from": null,
      "name": "disabled",
      "property": "disabled",
      "reflect": false,
      "tokens": null,
      "type": "boolean",
      "values": null
    },
    {
      "default": "''",
      "description": "Adds classes to named parts as `key: classes` pairs; a plain string targets the default part.",
      "from": "Base",
      "name": "cls",
      "property": "cls",
      "reflect": false,
      "tokens": null,
      "type": "string",
      "values": null
    },
    {
      "default": "''",
      "description": "Adds inline styles to named parts as `key: styles` pairs; a plain string targets the default part.",
      "from": "Base",
      "name": "stl",
      "property": "stl",
      "reflect": false,
      "tokens": null,
      "type": "string",
      "values": null
    }
  ],
  "category": "data",
  "children": [],
  "cssClasses": [
    {
      "appliesTo": "z-sortable",
      "class": ".z-sortable",
      "description": "Root class on the managed container.",
      "role": "root"
    },
    {
      "appliesTo": ".z-sortable",
      "class": ".z-sortable-drag",
      "description": "The floating clone that follows the pointer during a drag.",
      "role": "state"
    },
    {
      "appliesTo": ".z-sortable",
      "class": ".z-sortable-empty",
      "description": "State class on an empty container; reserves a minimum drop area.",
      "role": "state"
    },
    {
      "appliesTo": ".z-sortable",
      "class": ".z-sortable-handle",
      "description": "Drag-handle affordance with a grab cursor.",
      "role": "element"
    },
    {
      "appliesTo": ".z-sortable",
      "class": ".z-sortable-placeholder",
      "description": "The gap element marking the current drop position.",
      "role": "state"
    }
  ],
  "cssVars": [
    {
      "affects": [
        "z-index"
      ],
      "default": "1050",
      "description": "Stacking order of the floating drag clone.",
      "file": "src/css/kit-components/sortable.css",
      "kind": "base",
      "name": "--z-sortable-drag-z-index",
      "scope": ".z-sortable-drag",
      "syntax": "<integer>"
    },
    {
      "affects": [
        "min-height"
      ],
      "default": "3.5rem",
      "description": "Minimum height reserved by an empty container as a drop target.",
      "file": "src/css/kit-components/sortable.css",
      "kind": "base",
      "name": "--z-sortable-empty-min-height",
      "scope": ".z-sortable-empty",
      "syntax": "<length>"
    },
    {
      "affects": [
        "opacity"
      ],
      "default": "0",
      "description": "Opacity of the drop-position placeholder.",
      "file": "src/css/kit-components/sortable.css",
      "kind": "base",
      "name": "--z-sortable-placeholder-opacity",
      "scope": ".z-sortable-placeholder",
      "syntax": "<number>"
    }
  ],
  "dataHooks": [
    {
      "appliesTo": "descendant",
      "attribute": "data-fn",
      "description": "Marks a deferred `<template>` child whose content is mounted into the container on demand.",
      "from": "Controller",
      "role": "config",
      "values": [
        "template"
      ]
    },
    {
      "appliesTo": "descendant",
      "attribute": "data-sortable-handle",
      "description": "Marks a drag handle inside an item; only handles start drags when present.",
      "role": "config",
      "values": []
    },
    {
      "appliesTo": "descendant",
      "attribute": "data-sortable-item",
      "description": "Marks (and is auto-added to) sortable items.",
      "role": "config",
      "values": []
    },
    {
      "appliesTo": "descendant",
      "attribute": "data-sortable-nodrag",
      "description": "Excludes an item from dragging.",
      "role": "config",
      "values": []
    },
    {
      "appliesTo": "descendant",
      "attribute": "data-sortable-target",
      "description": "Marks the sortable container when `target` is unset.",
      "role": "config",
      "values": []
    },
    {
      "appliesTo": "descendant",
      "attribute": "data-value",
      "description": "Fallback identity used by `serialize()` when the serialized attribute is absent.",
      "role": "read-only",
      "values": []
    }
  ],
  "events": [
    {
      "bubbles": true,
      "cancelable": false,
      "description": "Fires on the receiving sortable when an item arrives from another group member. Detail includes the item and its new index.",
      "detail": {
        "fields": [
          {
            "name": "item",
            "type": "HTMLElement"
          },
          {
            "name": "index",
            "type": "number"
          },
          {
            "name": "from",
            "type": "Sortable"
          },
          {
            "name": "sortable",
            "type": "Sortable"
          }
        ],
        "type": "{ item: HTMLElement; index: number; from: Sortable; sortable: Sortable }"
      },
      "name": "z-sortable:added"
    },
    {
      "bubbles": true,
      "cancelable": false,
      "description": "Fires when a session is cancelled (Escape or a vetoed start) and the item returns to its origin.",
      "detail": {
        "fields": [
          {
            "name": "item",
            "type": "HTMLElement"
          },
          {
            "name": "sortable",
            "type": "this"
          }
        ],
        "type": "{ item: HTMLElement; sortable: this }"
      },
      "name": "z-sortable:cancel"
    },
    {
      "bubbles": true,
      "cancelable": false,
      "description": "Fires after any reorder with `item`, `action` (`moved`/`added`/`removed`), indices, and the serialized `values`.",
      "detail": {
        "fields": [
          {
            "name": "item",
            "type": "HTMLElement"
          },
          {
            "name": "action",
            "type": "\"moved\""
          },
          {
            "name": "index",
            "type": "number"
          },
          {
            "name": "previousIndex",
            "type": "number"
          },
          {
            "name": "values",
            "type": "string[]"
          }
        ],
        "type": "{ item: HTMLElement; action: \"moved\"; index: number; previousIndex: number; values: string[] }"
      },
      "name": "z-sortable:change"
    },
    {
      "bubbles": true,
      "cancelable": false,
      "description": "Fires when deferred template content is mounted into the container.",
      "detail": {
        "fields": [],
        "type": "Record<string, unknown>"
      },
      "from": "Controller",
      "name": "z-sortable:mount"
    },
    {
      "bubbles": true,
      "cancelable": false,
      "description": "Fires while the dragged item hovers a new position (and on keyboard moves). Detail includes the item and target index.",
      "detail": {
        "fields": [
          {
            "name": "item",
            "type": "HTMLElement"
          },
          {
            "name": "sortable",
            "type": "this"
          },
          {
            "name": "targetSortable",
            "type": "Sortable"
          }
        ],
        "type": "{ item: HTMLElement; sortable: this; targetSortable: Sortable }"
      },
      "name": "z-sortable:move"
    },
    {
      "bubbles": true,
      "cancelable": false,
      "description": "Fires after an item is moved (drag drop, keyboard drop, or `move()`). Detail: `item`, `index`, `previousIndex`, `sortable`.",
      "detail": {
        "fields": [
          {
            "name": "item",
            "type": "HTMLElement"
          },
          {
            "name": "index",
            "type": "number"
          },
          {
            "name": "previousIndex",
            "type": "number"
          },
          {
            "name": "sortable",
            "type": "this"
          }
        ],
        "type": "{ item: HTMLElement; index: number; previousIndex: number; sortable: this }"
      },
      "name": "z-sortable:moved"
    },
    {
      "bubbles": true,
      "cancelable": false,
      "description": "Fires on the origin sortable when an item leaves for another group member.",
      "detail": {
        "fields": [
          {
            "name": "item",
            "type": "HTMLElement"
          },
          {
            "name": "previousIndex",
            "type": "number"
          },
          {
            "name": "to",
            "type": "Sortable"
          },
          {
            "name": "sortable",
            "type": "Sortable"
          }
        ],
        "type": "{ item: HTMLElement; previousIndex: number; to: Sortable; sortable: Sortable }"
      },
      "name": "z-sortable:removed"
    },
    {
      "bubbles": true,
      "cancelable": true,
      "description": "Cancelable; fires when a drag or keyboard grab begins. Detail: `item`, `index`, `sortable`. `preventDefault()` cancels the session.",
      "detail": {
        "fields": [
          {
            "name": "item",
            "type": "HTMLElement"
          },
          {
            "name": "index",
            "type": "number"
          },
          {
            "name": "sortable",
            "type": "this"
          }
        ],
        "type": "{ item: HTMLElement; index: number; sortable: this }"
      },
      "name": "z-sortable:start"
    },
    {
      "bubbles": true,
      "cancelable": false,
      "description": "Fires when a drag or keyboard session ends, whether dropped or cancelled.",
      "detail": {
        "fields": [
          {
            "name": "item",
            "type": "HTMLElement"
          },
          {
            "name": "index",
            "type": "number"
          },
          {
            "name": "sortable",
            "type": "this"
          }
        ],
        "type": "{ item: HTMLElement; index: number; sortable: this }"
      },
      "name": "z-sortable:stop"
    }
  ],
  "i18n": [],
  "icons": [],
  "id": "sortable",
  "inherits": [
    "Controller",
    "Base"
  ],
  "keyboard": [
    {
      "action": "Grab the focused item (or its handle); press again to drop.",
      "keys": [
        "Space",
        "Enter"
      ]
    },
    {
      "action": "Move the grabbed item within the list.",
      "keys": [
        "ArrowUp",
        "ArrowDown",
        "ArrowLeft",
        "ArrowRight",
        "Home",
        "End"
      ],
      "when": "An item is grabbed."
    },
    {
      "action": "Move the grabbed item to the previous/next sortable in the same group (Alt+arrows also works).",
      "keys": [
        "PageUp",
        "PageDown"
      ],
      "when": "An item is grabbed and `group` is set."
    },
    {
      "action": "Cancel the grab or drag and return the item to its origin.",
      "keys": [
        "Escape"
      ]
    }
  ],
  "kind": "controller",
  "methods": [
    {
      "description": "Returns whether move animations are still running.",
      "name": "hasAnimatingItems",
      "params": [],
      "returns": "boolean",
      "static": false
    },
    {
      "description": "Inserts an element at an index with the move animation.",
      "name": "insertItemAnimated",
      "params": [
        {
          "default": null,
          "name": "item",
          "optional": false,
          "type": "HTMLElement"
        },
        {
          "default": null,
          "name": "reference",
          "optional": false,
          "type": "Element | null"
        }
      ],
      "returns": "void",
      "static": false
    },
    {
      "description": "Returns the current item elements in DOM order.",
      "name": "items",
      "params": [],
      "returns": "HTMLElement[]",
      "static": false
    },
    {
      "description": "Moves the item at `fromIndex` to `toIndex`, optionally without animation; fires `moved`/`change`/`stop`.",
      "name": "move",
      "params": [
        {
          "default": null,
          "name": "fromIndex",
          "optional": false,
          "type": "number"
        },
        {
          "default": null,
          "name": "toIndex",
          "optional": false,
          "type": "number"
        },
        {
          "default": "true",
          "name": "animate",
          "optional": true,
          "type": "boolean"
        }
      ],
      "returns": "Promise<void>",
      "static": false
    },
    {
      "description": "Re-syncs container/item classes, handles, and observers.",
      "name": "refresh",
      "params": [],
      "returns": "void",
      "static": false
    },
    {
      "description": "Removes an element with the move animation.",
      "name": "removeItemAnimated",
      "params": [
        {
          "default": null,
          "name": "item",
          "optional": false,
          "type": "HTMLElement"
        }
      ],
      "returns": "void",
      "static": false
    },
    {
      "description": "Returns the item order as strings: the given attribute (default `data-id`), falling back to `data-value` then `id`.",
      "name": "serialize",
      "params": [
        {
          "default": "'data-id'",
          "name": "attribute",
          "optional": true,
          "type": "string"
        }
      ],
      "returns": "string[]",
      "static": false
    }
  ],
  "notes": [
    "Dragging uses a floating clone plus a placeholder; the original item stays in the DOM until drop.",
    "Near viewport edges the page auto-scrolls while dragging.",
    "A MutationObserver keeps classes and handles in sync when items change; the follow-up click after a drag is suppressed."
  ],
  "parts": {
    "defaultClsTarget": "custom",
    "defaultStlTarget": "host-inner",
    "items": [
      {
        "defaultCls": "z-sortable",
        "description": "Class applied to the managed container (default `z-sortable`).",
        "foundIn": [
          "$cls"
        ],
        "key": "base",
        "supportsCls": true,
        "supportsStl": false
      },
      {
        "defaultCls": "",
        "description": "Extra class applied to the container; the default `cls` target for this component (empty by default).",
        "foundIn": [
          "$cls"
        ],
        "key": "custom",
        "supportsCls": true,
        "supportsStl": false
      },
      {
        "defaultCls": "z-sortable-drag",
        "description": "Class of the floating drag clone (default `z-sortable-drag`).",
        "foundIn": [
          "$cls"
        ],
        "key": "drag",
        "supportsCls": true,
        "supportsStl": false
      },
      {
        "defaultCls": "z-drag",
        "description": "Class applied to `<html>` while a drag is active (default `z-drag`), forcing grabbing cursors.",
        "foundIn": [
          "$cls",
          "render"
        ],
        "key": "drag-state",
        "supportsCls": true,
        "supportsStl": false
      },
      {
        "defaultCls": "z-sortable-empty",
        "description": "Class applied to the container when it has no items (default `z-sortable-empty`).",
        "foundIn": [
          "$cls"
        ],
        "key": "empty",
        "supportsCls": true,
        "supportsStl": false
      },
      {
        "defaultCls": "z-sortable-item",
        "description": "Class applied to each sortable item (default `z-sortable-item`).",
        "foundIn": [
          "$cls"
        ],
        "key": "item",
        "supportsCls": true,
        "supportsStl": false
      },
      {
        "defaultCls": "z-sortable-nodrag",
        "description": "Class applied to non-draggable items (default `z-sortable-nodrag`).",
        "foundIn": [
          "$cls",
          "render"
        ],
        "key": "no-drag",
        "supportsCls": true,
        "supportsStl": false
      },
      {
        "defaultCls": "z-sortable-placeholder",
        "description": "Class of the gap element left at the drag position (default `z-sortable-placeholder`).",
        "foundIn": [
          "$cls"
        ],
        "key": "placeholder",
        "supportsCls": true,
        "supportsStl": false
      }
    ]
  },
  "recipes": [],
  "related": [
    "filter"
  ],
  "schemaVersion": 1,
  "sources": {
    "css": [
      "src/css/kit-components/sortable.css"
    ],
    "cssSelectors": [
      ".z-sortable",
      ".z-sortable-*"
    ],
    "ts": "src/js/controllers/components/sortable.ts"
  },
  "summary": "Drag-and-drop reordering for lists, grids, and tables, with handles, cross-list groups, keyboard grabbing, and animated moves.",
  "tag": "z-sortable",
  "title": "Sortable"
}
