{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "date-picker",
  "type": "registry:ui",
  "title": "DatePicker",
  "description": "DatePicker is a single-date input that pairs a text-style trigger with a calendar popover.",
  "dependencies": [
    "@remixicon/react@^4.9.0",
    "class-variance-authority@^0.7.1",
    "react-day-picker@^9.11.1"
  ],
  "registryDependencies": [
    "https://wideset.co/r/calendar.json",
    "https://wideset.co/r/logic.json",
    "https://wideset.co/r/motion.json",
    "https://wideset.co/r/popup.json",
    "https://wideset.co/r/styles.json",
    "https://wideset.co/r/text-input.json",
    "https://wideset.co/r/utils.json"
  ],
  "files": [
    {
      "path": "src/components/datepicker/DatePicker.tsx",
      "type": "registry:ui",
      "target": "components/ui/wideset/datepicker/DatePicker.tsx",
      "content": "'use client';\n\nimport { forwardRef, useState } from 'react';\nimport type { OnSelectHandler } from 'react-day-picker';\nimport { formatDateToISOString, formatISODateToAnotherFormat, parseISODate } from '@/lib/wideset/date';\n\nimport { useDefaultMotion } from '@/lib/wideset/motion/MotionProvider';\nimport { Calendar } from '../calendar/Calendar';\nimport { Popup } from '../popup/Popup';\nimport type { DatePickerProps } from './DatePicker.types';\nimport { DatePickerTrigger } from './DatePickerTrigger';\n\nconst DatePicker = forwardRef<HTMLButtonElement, DatePickerProps>(\n  (\n    {\n      className,\n      id,\n      'aria-label': ariaLabel,\n      'aria-labelledby': ariaLabelledBy,\n      'aria-describedby': ariaDescribedBy,\n      'aria-invalid': ariaInvalid,\n      onSelect,\n      selected,\n      defaultSelected,\n      dateFormat,\n      placeholder = 'Pick a date',\n      size,\n      preset,\n      variant,\n      disabled,\n      disabledDates,\n      defaultMotion,\n      ...calendarProps\n    },\n    ref,\n  ) => {\n    const motion = useDefaultMotion(defaultMotion);\n    const [isOpen, setIsOpen] = useState(false);\n    const [internalSelected, setInternalSelected] = useState<string | undefined>(defaultSelected);\n\n    const isControlled = selected !== undefined;\n    const currentSelected = isControlled ? selected : internalSelected;\n\n    const handleSelect: OnSelectHandler<Date | undefined> = (day) => {\n      const iso = formatDateToISOString(day);\n      if (!isControlled) setInternalSelected(iso);\n      setIsOpen(false);\n      onSelect?.(iso);\n    };\n\n    return (\n      <Popup onOpenChange={setIsOpen} open={isOpen}>\n        <Popup.Trigger asChild>\n          <DatePickerTrigger\n            data-slot=\"date-picker\"\n            ref={ref}\n            id={id}\n            aria-label={ariaLabel}\n            aria-labelledby={ariaLabelledBy}\n            aria-describedby={ariaDescribedBy}\n            aria-invalid={ariaInvalid}\n            className={className}\n            placeholder={placeholder}\n            value={formatISODateToAnotherFormat(currentSelected, dateFormat) ?? ''}\n            size={size}\n            preset={preset}\n            variant={variant}\n            disabled={disabled}\n            defaultMotion={motion}\n          />\n        </Popup.Trigger>\n        <Popup.Container align=\"start\" className=\"w-auto\" defaultMotion={motion}>\n          <Calendar\n            {...calendarProps}\n            selected={parseISODate(currentSelected)}\n            onSelect={handleSelect}\n            mode=\"single\"\n            disabled={disabledDates}\n            defaultMotion={motion}\n          />\n        </Popup.Container>\n      </Popup>\n    );\n  },\n);\nDatePicker.displayName = 'DatePicker';\n\nexport { DatePicker };\n"
    },
    {
      "path": "src/components/datepicker/DatePicker.types.ts",
      "type": "registry:ui",
      "target": "components/ui/wideset/datepicker/DatePicker.types.ts",
      "content": "import type { VariantProps } from 'class-variance-authority';\nimport type { AriaAttributes } from 'react';\nimport type { Matcher, PropsBase, PropsSingle } from 'react-day-picker';\n\nimport type { MotionProps } from '@/lib/wideset/motion/Motion.types';\nimport type { textInputVariants } from '../text-input/TextInput.variants';\n\ntype DatePickerVariants = Pick<\n  VariantProps<typeof textInputVariants>,\n  'size' | 'preset' | 'variant'\n>;\n\n/** A single date picker with an anchored calendar. */\nexport type DatePickerProps = DatePickerVariants &\n  MotionProps &\n  Omit<\n    PropsBase,\n    'mode' | 'disabled' | 'id' | 'aria-label' | 'aria-labelledby' | 'aria-describedby'\n  > &\n  Omit<PropsSingle, 'mode' | 'selected' | 'onSelect' | 'defaultSelected'> & {\n    /** Additional class name forwarded to the trigger element. */\n    className?: string;\n    /** Id of the trigger button, so a `<label htmlFor>` can name it. */\n    id?: string;\n    /** Accessible name of the trigger button when no visible label is associated. */\n    'aria-label'?: string;\n    /** Id of the element that names the trigger button. */\n    'aria-labelledby'?: string;\n    /** Ids of the elements that describe the trigger button, such as a FormField's helper text. */\n    'aria-describedby'?: string;\n    /** Marks the trigger button invalid; FormField sets it while it shows an error. */\n    'aria-invalid'?: AriaAttributes['aria-invalid'];\n    /** date-fns format string used to render the selected date in the trigger (e.g. `'MMMM d, yyyy'`). */\n    dateFormat?: string;\n    /** Placeholder shown in the trigger when no date is selected. Defaults to `'Pick a date'`. */\n    placeholder?: string;\n    /** Initial selected date in ISO format (`YYYY-MM-DD`). Uncontrolled — seeds internal state only. */\n    defaultSelected?: string;\n    /** Selected date in ISO format (`YYYY-MM-DD`). Provide to make the component controlled. */\n    selected?: string;\n    /** Disables the trigger and prevents the popup from opening. */\n    disabled?: boolean;\n    /** Dates or matchers that should be unselectable inside the calendar grid. */\n    disabledDates?: Matcher | Matcher[];\n    /** Fired when a date is picked. Receives the ISO date string (`YYYY-MM-DD`), or `undefined` if cleared. */\n    onSelect?: (day?: string) => void;\n  };\n\n/** The control that opens or toggles the associated content. */\nexport type DatePickerTriggerProps = Pick<\n  DatePickerProps,\n  | 'className'\n  | 'id'\n  | 'aria-label'\n  | 'aria-labelledby'\n  | 'aria-describedby'\n  | 'aria-invalid'\n  | 'size'\n  | 'preset'\n  | 'variant'\n  | 'placeholder'\n  | 'defaultMotion'\n> & {\n  /** Disables the trigger button. */\n  disabled?: boolean;\n  /** Formatted date string displayed inside the trigger input. */\n  value?: string;\n};\n"
    },
    {
      "path": "src/components/datepicker/DatePicker.variants.ts",
      "type": "registry:ui",
      "target": "components/ui/wideset/datepicker/DatePicker.variants.ts",
      "content": "import { cva } from 'class-variance-authority';\nimport { cn } from '@/lib/wideset/utils';\n\nimport { hoverTintMotion, pressMotion } from '@/lib/wideset/motion/recipes';\n\nexport const datePickerTriggerVariants = cva('focus-within:outline-hidden', {\n  variants: {\n    preset: {\n      border: '',\n      ghost: 'shadow-none',\n    },\n    variant: {\n      primary: cn(\n        'group-focus-visible:border-ws-dynamic-primary-strong-default',\n        'group-focus-visible:shadow-ws-forms-active',\n      ),\n      danger: cn(\n        'group-focus-visible:border-ws-dynamic-danger-strong-default',\n        'group-focus-visible:shadow-ws-forms-active-danger',\n      ),\n    },\n  },\n  defaultVariants: {\n    preset: 'border',\n    variant: 'primary',\n  },\n});\n\nexport const datePickerTriggerMotionVariants = cva('', {\n  variants: {\n    enabled: { true: cn(hoverTintMotion, pressMotion), false: '' },\n  },\n  defaultVariants: { enabled: true },\n});\n"
    },
    {
      "path": "src/components/datepicker/DatePickerTrigger.tsx",
      "type": "registry:ui",
      "target": "components/ui/wideset/datepicker/DatePickerTrigger.tsx",
      "content": "'use client';\n\nimport { RiCalendarLine } from '@remixicon/react';\nimport React from 'react';\nimport { cn } from '@/lib/wideset/utils';\n\nimport { useDefaultMotion } from '@/lib/wideset/motion/MotionProvider';\nimport { TextInput } from '../text-input/TextInput';\nimport type { DatePickerTriggerProps } from './DatePicker.types';\nimport { datePickerTriggerMotionVariants, datePickerTriggerVariants } from './DatePicker.variants';\n\nconst DatePickerTrigger = React.forwardRef<HTMLButtonElement, DatePickerTriggerProps>(\n  (\n    {\n      className,\n      placeholder,\n      value,\n      size,\n      preset,\n      variant,\n      disabled,\n      defaultMotion,\n      'aria-describedby': ariaDescribedBy,\n      ...props\n    },\n    ref,\n  ) => {\n    const motion = useDefaultMotion(defaultMotion);\n    const isGhost = preset === 'ghost';\n    const valueId = React.useId();\n    // Named from outside (`aria-label`, `aria-labelledby` or a `<label htmlFor>` on `id`), the\n    // button no longer announces its content, so the selected value becomes its description.\n    // Unnamed, the value already is the name; describing it again would read it twice.\n    const isNamedExternally = Boolean(props['aria-label'] || props['aria-labelledby'] || props.id);\n    const describedBy =\n      [ariaDescribedBy, isNamedExternally && value ? valueId : undefined]\n        .filter(Boolean)\n        .join(' ') || undefined;\n\n    return (\n      <button\n        className={cn(\n          'group wds-focus-visible rounded-ws-control-lg w-full cursor-pointer outline-hidden disabled:cursor-default',\n          datePickerTriggerMotionVariants({ enabled: motion }),\n          className,\n        )}\n        ref={ref}\n        disabled={disabled}\n        type=\"button\"\n        data-slot=\"date-picker-trigger\"\n        {...props}\n        aria-describedby={describedBy}\n      >\n        <TextInput\n          size={size}\n          preset={preset}\n          variant={variant}\n          disabled={disabled}\n          defaultMotion={motion}\n          className={datePickerTriggerVariants({ preset, variant })}\n        >\n          {isGhost && (\n            <TextInput.Prefix inner>\n              <TextInput.Icon\n                icon={RiCalendarLine}\n                className={cn('text-ws-dynamic-secondary-default', size === 'lg' && 'size-ws-11')}\n              />\n            </TextInput.Prefix>\n          )}\n          <TextInput.Input\n            placeholder={placeholder}\n            value={value}\n            readOnly\n            tabIndex={-1}\n            aria-hidden\n            className=\"cursor-pointer\"\n          />\n          <span id={valueId} className=\"sr-only\">\n            {value || placeholder}\n          </span>\n          {!isGhost && (\n            <TextInput.Suffix inner>\n              <TextInput.Icon\n                icon={RiCalendarLine}\n                className={cn('text-ws-dynamic-secondary-default', size === 'lg' && 'size-ws-11')}\n              />\n            </TextInput.Suffix>\n          )}\n        </TextInput>\n      </button>\n    );\n  },\n);\nDatePickerTrigger.displayName = 'DatePickerTrigger';\n\nexport { DatePickerTrigger };\n"
    }
  ],
  "meta": {
    "version": "1.0.0",
    "commit": "8bb3627"
  }
}
