{
  "package": "@blade-ai/weft",
  "status": "beta",
  "version": "0.1.0",
  "updated": "2026-11-24",
  "component": "DatePicker",
  "import": "import { DatePicker } from \"@blade-ai/weft/components/date-picker\";",
  "docs": "/components/date-picker",
  "description": "Types or picks one date, or a start and end date, from a calendar. A text field with a calendar button opens a dialog with a month grid; square, flat and token-driven.",
  "props": [
    {
      "name": "selectionType",
      "type": "\"single\" | \"range\"",
      "values": [
        "single",
        "range"
      ],
      "default": "single",
      "required": false,
      "description": "One date, or a start and end date in one field."
    },
    {
      "name": "value",
      "type": "Date | null | [Date | null, Date | null]",
      "default": null,
      "required": false,
      "description": "Controlled value. Range uses a [start, end] tuple; either end can be null while picking. Dates are JS Date objects at local midnight."
    },
    {
      "name": "defaultValue",
      "type": "Date | null | [Date | null, Date | null]",
      "default": null,
      "required": false,
      "description": "Uncontrolled starting value."
    },
    {
      "name": "onChange",
      "type": "(value) => void",
      "default": null,
      "required": false,
      "description": "Called when the committed value changes (Apply, a pick with no footer, or a valid typed date)."
    },
    {
      "name": "onApply",
      "type": "(value) => void",
      "default": null,
      "required": false,
      "description": "Called with the value when Apply is pressed, before the popup closes."
    },
    {
      "name": "minDate · maxDate",
      "type": "Date",
      "default": null,
      "required": false,
      "description": "Days outside are disabled in the grid; typed values outside show an error."
    },
    {
      "name": "isDateDisabled",
      "type": "(date: Date) => boolean",
      "default": null,
      "required": false,
      "description": "Disables single days, for example bank holidays."
    },
    {
      "name": "isOpen · defaultIsOpen",
      "type": "boolean",
      "default": false,
      "required": false,
      "description": "Controlled / uncontrolled popup state."
    },
    {
      "name": "onOpenChange",
      "type": "(isOpen: boolean) => void",
      "default": null,
      "required": false,
      "description": "Called when the popup opens or closes."
    },
    {
      "name": "presets",
      "type": "{ label, value: (today) => [Date, Date] }[]",
      "default": null,
      "required": false,
      "description": "Range shortcuts in a column left of the calendar. Range only. Chips on mobile: UNDEFINED · not built."
    },
    {
      "name": "showFooterActions",
      "type": "boolean",
      "default": true,
      "required": false,
      "description": "Cancel / Apply footer. When false, a pick commits and closes at once."
    },
    {
      "name": "picker",
      "type": "\"day\" | \"month\" | \"year\"",
      "values": [
        "day",
        "month",
        "year"
      ],
      "default": "day",
      "required": false,
      "description": "Granularity. Range supports day only. Month and year views are not drawn in Paper: UNDEFINED · needs decision; they fall back to \"day\"."
    },
    {
      "name": "firstDayOfWeek",
      "type": "0 | 1 | 2 | 3 | 4 | 5 | 6",
      "default": 1,
      "required": false,
      "description": "First column of the grid (0 = Sunday)."
    },
    {
      "name": "locale · format",
      "type": "string · string",
      "default": "en-IN · DD/MM/YYYY",
      "required": false,
      "description": "Month and weekday names, and the typed / displayed format built from DD, MM and YYYY."
    },
    {
      "name": "label · accessibilityLabel",
      "type": "string",
      "default": null,
      "required": false,
      "description": "Visible label, or an accessible name when there is none. One of the two is required."
    },
    {
      "name": "helpText · errorText",
      "type": "ReactNode",
      "default": null,
      "required": false,
      "description": "Same as Text Input. errorText shows when validationState = \"error\" and replaces helpText."
    },
    {
      "name": "validationState",
      "type": "\"none\" | \"error\" | \"success\"",
      "values": [
        "none",
        "error",
        "success"
      ],
      "default": "none",
      "required": false,
      "description": "Validation feedback."
    },
    {
      "name": "size",
      "type": "\"small\" | \"medium\" | \"large\"",
      "values": [
        "small",
        "medium",
        "large"
      ],
      "default": "medium",
      "required": false,
      "description": "Trigger height 32 · 36 · 48, same as Text Input."
    },
    {
      "name": "isDisabled · isReadOnly · isRequired",
      "type": "boolean",
      "default": false,
      "required": false,
      "description": "Read-only has no Theme treatment (same gap as Text Input): UNDEFINED · needs decision."
    },
    {
      "name": "autoFocus · name · testID",
      "type": "boolean · string · string",
      "default": false,
      "required": false,
      "description": "Focuses the text input, never opens the popup · form field name (ISO value) · test selector."
    }
  ],
  "states": [
    {
      "name": "trigger · default",
      "trigger": "Closed, empty",
      "tokens": "bg surface.background.gray.subtle · border interactive.border.gray.default · text surface.text.gray.muted (placeholder) · icon surface.icon.gray.muted",
      "notes": "Placeholder shows the format (DD/MM/YYYY)."
    },
    {
      "name": "trigger · hover",
      "trigger": "Pointer over the field or the calendar icon",
      "tokens": "border interactive.border.gray.highlighted",
      "notes": "No ring."
    },
    {
      "name": "trigger · focus-visible",
      "trigger": "Keyboard focus",
      "tokens": "border interactive.border.primary.default · ring 3px interactive.border.primary.faded",
      "notes": "Focus does not open the calendar."
    },
    {
      "name": "trigger · open",
      "trigger": "Calendar popover open",
      "tokens": "border interactive.border.primary.default · icon interactive.icon.gray.normal · popover popup.background.gray.subtle · popup.border.gray.subtle · shadow elevation.mid.raised",
      "notes": "aria-expanded=\"true\". Open-state ring: UNDEFINED · needs decision (none drawn)."
    },
    {
      "name": "trigger · filled",
      "trigger": "Value set",
      "tokens": "text surface.text.gray.normal",
      "notes": "Value shown in format; range shows 01/10/2026 – 07/10/2026 in one field."
    },
    {
      "name": "trigger · disabled",
      "trigger": "isDisabled",
      "tokens": "bg interactive.background.gray.disabled · border interactive.border.gray.default · opacity opacity.600",
      "notes": "No hover, no focus, cannot open, not sent with the form."
    },
    {
      "name": "trigger · read-only",
      "trigger": "isReadOnly",
      "tokens": "UNDEFINED · needs decision (shown with filled tokens)",
      "notes": "Focusable, sent with the form; the calendar does not open."
    },
    {
      "name": "trigger · invalid",
      "trigger": "validationState = \"error\" or an unparseable / out-of-range typed value",
      "tokens": "border feedback.border.negative.intense · error text feedback.text.negative.intense",
      "notes": "Error text says how to fix it. Focused + invalid: UNDEFINED · needs decision."
    },
    {
      "name": "day · default",
      "trigger": "Any available day",
      "tokens": "bg transparent · text interactive.text.gray.normal",
      "notes": "Square cells, radius none."
    },
    {
      "name": "day · hover",
      "trigger": "Pointer over an available day",
      "tokens": "bg interactive.background.gray.faded",
      "notes": "Selected and range days keep their fill (primary.highlighted)."
    },
    {
      "name": "day · focus-visible",
      "trigger": "Keyboard focus",
      "tokens": "ring 3px interactive.border.primary.faded",
      "notes": "Roving tabindex: one day is focusable."
    },
    {
      "name": "day · today",
      "trigger": "Today",
      "tokens": "text interactive.text.gray.normal · weight fonts.weight.semibold · 1px interactive.border.gray.default outline (proposal)",
      "notes": "aria-current=\"date\". No Theme token describes \"today\": UNDEFINED · needs decision."
    },
    {
      "name": "day · selected",
      "trigger": "Selected date",
      "tokens": "bg interactive.background.primary.default (hover primary.highlighted) · text interactive.text.onPrimary.normal",
      "notes": "aria-selected=\"true\"; weight medium."
    },
    {
      "name": "day · in-range",
      "trigger": "Between start and end",
      "tokens": "bg interactive.background.primary.faded (hover primary.fadedHighlighted) · text interactive.text.gray.normal",
      "notes": "Cells touch so the band reads as one strip. Hover previews the end while picking."
    },
    {
      "name": "day · range start / end",
      "trigger": "Either end",
      "tokens": "bg interactive.background.primary.default · text interactive.text.onPrimary.normal",
      "notes": "Start = end is allowed. Distinguishing start from end visually: UNDEFINED · needs decision."
    },
    {
      "name": "day · outside-month",
      "trigger": "Leading / trailing days",
      "tokens": "text interactive.text.gray.muted",
      "notes": "Selectable; picking one moves the view to that month."
    },
    {
      "name": "day · disabled",
      "trigger": "Before minDate, after maxDate, or isDateDisabled",
      "tokens": "text interactive.text.gray.disabled · line-through",
      "notes": "aria-disabled=\"true\"; focus can land on it; click and Enter do nothing."
    }
  ],
  "sizes": [
    {
      "property": "Trigger height",
      "value": "32 · 36 · 48",
      "token": "size.32 · size.36 · size.48"
    },
    {
      "property": "Trigger padding-x · gap",
      "value": "8 · 8 / 12 · 8 / 12 · 8",
      "token": "spacing.3 · spacing.3 / spacing.4 · spacing.3"
    },
    {
      "property": "Icon size",
      "value": "14 · 16 · 16",
      "token": "size.14 · size.16 · size.16"
    },
    {
      "property": "Value font size",
      "value": "13 · 13 · 14",
      "token": "fonts.size.1200 · fonts.size.1200 · fonts.size.100"
    },
    {
      "property": "Day cell (square)",
      "value": "32 · 36 · 40",
      "token": "size.32 · size.36 · size.40"
    },
    {
      "property": "Day font size",
      "value": "13 · 13 · 14",
      "token": "fonts.size.1200 · fonts.size.1200 · fonts.size.100"
    },
    {
      "property": "Calendar padding",
      "value": "12 · 12 · 16",
      "token": "spacing.4 · spacing.4 · spacing.5"
    },
    {
      "property": "Border · radius",
      "value": "1px · 0",
      "token": "border.width.thin · border.radius.none"
    },
    {
      "property": "Popover width",
      "value": "7 × day size + 2 × padding; presets column 160",
      "token": "literal 160 for presets"
    }
  ],
  "behaviour": {
    "open": "Calendar button click, Enter, Space or Alt+↓. Focusing or typing in the field never opens it.",
    "close": "Esc, click outside, Cancel, or a pick when showFooterActions = false. Focus returns to the trigger.",
    "select · single": "One click/Enter sets the date. With footer: commits on Apply; without: commits and closes.",
    "select · range": "First pick = start, second = end; hover previews the band. Apply commits both ends.",
    "footer actions": "Cancel restores the last committed value. Apply calls onApply then closes.",
    "presets": "Range only. Picking a preset fills both ends and moves the view; Apply still commits.",
    "typing": "Field accepts the format (DD/MM/YYYY). Parsed on blur and Enter; the calendar follows.",
    "paste": "Strips punctuation where the format applies, then re-inserts separators (15.10.2026 → 15/10/2026).",
    "validate": "On blur and on submit: an unparseable, outside min/max or disabled typed date shows an error (generated copy \"Enter a date as DD/MM/YYYY.\" when no errorText is passed).",
    "error clears": "The error clears on re-validate once the value is valid (no clearing on every keystroke).",
    "autoFocus": "Goes to the text input; never opens the popup.",
    "min · max · isDateDisabled": "Days outside the range are disabled (aria-disabled), not hidden; typed values outside are errors.",
    "outside-month click": "Selects that day and moves the view to its month.",
    "view month on open": "Shows the month of the value, else today. Range shows the start month.",
    "range end before start": "UNDEFINED · needs decision: swap the ends, or restart the range from that day. Fallback: restart.",
    "mobile": "< 768px bottom sheet with large days: UNDEFINED · not built (no BottomSheet component).",
    "clear value": "UNDEFINED · needs decision: clear button in the field (Text Input has isClearable). Emptying the text clears the value.",
    "month / year views": "The month/year header view is not drawn in Paper: UNDEFINED · needs decision. The title is static text."
  },
  "keyboard": [
    {
      "key": "Tab / Shift+Tab",
      "action": "Field → calendar button. Inside the dialog: grid → header → presets → Cancel → Apply (trapped)."
    },
    {
      "key": "Enter · Space · Alt+↓",
      "action": "On the calendar button: open the dialog and focus the selected day (else today)."
    },
    {
      "key": "← / →",
      "action": "Previous / next day."
    },
    {
      "key": "↑ / ↓",
      "action": "Same weekday previous / next week."
    },
    {
      "key": "Home / End",
      "action": "First / last day of the week (firstDayOfWeek aware)."
    },
    {
      "key": "PageUp / PageDown",
      "action": "Same day previous / next month (clamped to month length)."
    },
    {
      "key": "Shift+PageUp / PageDown",
      "action": "Same day previous / next year."
    },
    {
      "key": "Enter / Space (day)",
      "action": "Select the day. Range: first = start, second = end."
    },
    {
      "key": "Esc",
      "action": "Close, keep the committed value, focus the trigger."
    }
  ],
  "accessibility": {
    "summary": "APG Date Picker Dialog pattern: an editable text field, a calendar button and a modal dialog with a grid.",
    "aria": [
      {
        "element": "input",
        "attributes": "aria-describedby = id of helpText or errorText",
        "when": "Help or error shown"
      },
      {
        "element": "input",
        "attributes": "aria-invalid=\"true\" · autocomplete=\"off\"",
        "when": "validationState = \"error\""
      },
      {
        "element": "button",
        "attributes": "aria-label=\"Choose date\" · \"Change date, 24/11/2026\" · aria-haspopup=\"dialog\" · aria-expanded",
        "when": "Always (range: \"Choose date range\")"
      },
      {
        "element": "dialog",
        "attributes": "role=\"dialog\" · aria-modal=\"true\" · aria-label=\"Choose date\"",
        "when": "Open"
      },
      {
        "element": "heading",
        "attributes": "aria-live=\"polite\" (month/year title)",
        "when": "Open"
      },
      {
        "element": "grid",
        "attributes": "<table role=\"grid\"> · aria-labelledby = id of the month/year heading",
        "when": "Open"
      },
      {
        "element": "th",
        "attributes": "abbr = full weekday name",
        "when": "Always"
      },
      {
        "element": "gridcell button",
        "attributes": "aria-label = full date, plus \"start\" / \"end\" in range",
        "when": "Each day"
      },
      {
        "element": "gridcell button",
        "attributes": "aria-selected=\"true\" (cell) on selected days and range ends",
        "when": "Selected"
      },
      {
        "element": "gridcell button",
        "attributes": "aria-current=\"date\"",
        "when": "Today"
      },
      {
        "element": "gridcell button",
        "attributes": "aria-disabled=\"true\"",
        "when": "Outside min/max or isDateDisabled"
      },
      {
        "element": "gridcell button",
        "attributes": "tabindex 0 on one day (roving), -1 on the rest",
        "when": "Open"
      }
    ]
  },
  "usage": {
    "do": [
      "Keep the text field editable; the calendar is a helper.",
      "Show the format as the placeholder (DD/MM/YYYY).",
      "Use one range picker for a period, not two single pickers.",
      "Use only Theme tokens for colour and Global tokens for size, spacing and type.",
      "Return focus to the trigger whenever the dialog closes."
    ],
    "dont": [
      "Open the calendar on focus or on autoFocus.",
      "Hide disabled days; mark them aria-disabled instead.",
      "Rely on the lime fill alone to show selection.",
      "Add component tokens (datepicker/*) or round the cells.",
      "Write \"Invalid date\"; say how to fix it."
    ]
  },
  "example": "<DatePicker label=\"Settlement date\" minDate={new Date()} helpText=\"Blade AI pays out on this date.\" onChange={setSettlementDate} />"
}
