# DatePicker

Native modal calendar picker with focus restoration and ISO form values.

[All components](https://rickylabs.github.io/netscript/design-system/components/) · [Theme builder](https://rickylabs.github.io/netscript/create/) · [Implementation source](https://github.com/rickylabs/netscript/blob/main/packages/fresh-ui/registry/components/ui/date-picker.tsx)

## Live preview

[Open live date-picker preview](https://rickylabs.github.io/netscript/assets/fresh-ui/preview/?component=date-picker&theme=studio-utility)

## Install

```bash
netscript ui:add date-picker
```

## Usage and examples

The preview runs this JSX with the installed components. Import any composed primitives from your UI directory.

```tsx
import { useState } from 'preact/hooks';
import { DatePicker } from '@app/components/ui/date-picker.tsx';

export function Example() {
  const [value, setValue] = useState('standard');
  const [open, setOpen] = useState(false);
  const [notice, report] = useState('');
  return (<><div><DatePicker label="Delivery date" defaultMonth="2026-11-01" /></div><p role="status">{notice}</p></>);
}
```

## Props

Generated from native `deno doc --json --private` over the shipped implementation. Compound component props retain their owning interface; native attributes pass through where declared.

| Owner | Prop | Type | Optional | Description |
| --- | --- | --- | --- | --- |
| `DatePickerProps` | `label` | `string` | No |  |
| `DatePickerProps` | `name` | `string` | Yes |  |
| `DatePickerProps` | `mode` | `"single" \| "range"` | Yes |  |
| `DatePickerProps` | `value` | `[object Object]` | Yes |  |
| `DatePickerProps` | `defaultValue` | `[object Object]` | Yes |  |
| `DatePickerProps` | `onValueChange` | `(dates: [object Object]) => void` | Yes |  |
| `DatePickerProps` | `open` | `boolean` | Yes |  |
| `DatePickerProps` | `defaultOpen` | `boolean` | Yes |  |
| `DatePickerProps` | `onOpenChange` | `(open: boolean) => void` | Yes |  |
| `DatePickerProps` | `defaultMonth` | `string` | Yes |  |
| `DatePickerProps` | `min` | `string` | Yes |  |
| `DatePickerProps` | `max` | `string` | Yes |  |
| `DatePickerProps` | `disabled` | `boolean` | Yes |  |
| `DatePickerProps` | `state` | `"rest" \| "focus" \| "disabled" \| "invalid"` | Yes |  |
| `DatePickerProps` | `placeholder` | `string` | Yes |  |
| `DatePickerProps` | `locale` | `string` | Yes |  |
| `DatePickerProps` | `class` | `string` | Yes |  |

```typescript
DatePickerProps extends Omit<JSX.HTMLAttributes<HTMLDivElement>, "class" | "onChange">
```

## Keyboard

| Key | Action |
| --- | --- |
| `Tab/Shift+Tab` | Cycle focus within modal |
| `Escape` | Dismiss and restore trigger focus |

## Tokens

Semantic contract roles: `surface/card`, `text/fg`.

CSS custom properties referenced directly: `--ns-border`, `--ns-border-width`, `--ns-card`, `--ns-control-gap`, `--ns-control-height`, `--ns-control-height-sm`, `--ns-control-padding-x`, `--ns-destructive`, `--ns-fg`, `--ns-floating-anchor-name`, `--ns-input-border`, `--ns-radius-card`, `--ns-radius-control`, `--ns-radius-input`, `--ns-ring`, `--ns-space-2`, `--ns-space-4`, `--ns-surface-raised`, `--ns-text-small`.

## Contract and compatibility

Accessibility pattern: [WAI-ARIA guidance](https://www.w3.org/WAI/ARIA/apg/patterns/dialog-modal/)

- Calendar embedded in package-owned native modal Dialog; uses existing focus, Escape and return behavior.
- Browser-forced dismissal can supersede a rejected close request; applications should normally accept native close requests.
- ISO value collection and open state can each be controlled. A named hidden input submits dates joined by /. Open data-state is derived; hydrate in an island.

Design contract values marked planned are not implementation props. The props above describe what ships today.
