{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "timepicker",
  "type": "registry:ui",
  "title": "TimePicker",
  "description": "TimePicker lets the user pick a time from hour and minute selects.",
  "dependencies": [
    "date-fns@^4.1.0"
  ],
  "registryDependencies": [
    "https://wideset.co/r/select.json",
    "https://wideset.co/r/styles.json",
    "https://wideset.co/r/utils.json"
  ],
  "files": [
    {
      "path": "src/components/timepicker/Timepicker.logic.ts",
      "type": "registry:ui",
      "target": "components/ui/wideset/timepicker/Timepicker.logic.ts",
      "content": "import { addMinutes, format, isBefore, isEqual, parse } from 'date-fns';\n\nimport type { TimePickerProps } from './Timepicker.types';\n\nexport const generateTimePickerSteps = ({\n  min = '00:00',\n  max = '23:59',\n  interval = 15,\n  mode,\n}: {\n  min?: string;\n  max?: string;\n  interval?: number;\n  mode?: 'from' | 'to' | undefined;\n} = {}) => {\n  if (interval <= 0) {\n    return [];\n  }\n\n  const minTime = parse(min, 'HH:mm', new Date());\n  const maxTime = parse(max, 'HH:mm', new Date());\n\n  if (isNaN(minTime.getTime()) || isNaN(maxTime.getTime())) {\n    console.warn(\n      `TimePicker: invalid min/max format. Expected \"HH:mm\", got min=\"${min}\" max=\"${max}\"`,\n    );\n    return [];\n  }\n\n  const steps = [];\n\n  let currentTime = minTime;\n  while (isBefore(currentTime, maxTime) || isEqual(currentTime, maxTime)) {\n    steps.push(format(currentTime, 'HH:mm'));\n    currentTime = addMinutes(currentTime, interval);\n  }\n\n  return mode === 'from' ? steps.slice(0, -1) : mode === 'to' ? steps.slice(1) : steps;\n};\n\nexport const stepsToOptions = (steps: string[], timeFormat: TimePickerProps['format'] = '24h') =>\n  steps.map((step) => ({\n    label: timeFormat === '24h' ? step : format(parse(step, 'HH:mm', new Date()), 'hh:mm a'),\n    value: step,\n  }));\n"
    },
    {
      "path": "src/components/timepicker/Timepicker.tsx",
      "type": "registry:ui",
      "target": "components/ui/wideset/timepicker/Timepicker.tsx",
      "content": "'use client';\n\nimport { useMemo } from 'react';\n\nimport { Select } from '../select/Select';\nimport { generateTimePickerSteps, stepsToOptions } from './Timepicker.logic';\nimport type { TimePickerProps } from './Timepicker.types';\n\nexport const TimePicker = ({\n  min,\n  max,\n  intervalInMinutes,\n  format = '24h',\n  mode,\n  ...selectProps\n}: TimePickerProps) => {\n  const options = useMemo(\n    () =>\n      stepsToOptions(\n        generateTimePickerSteps({ min, max, interval: intervalInMinutes, mode }),\n        format,\n      ),\n    [min, max, intervalInMinutes, format, mode],\n  );\n\n  return (\n    <Select\n      data-slot=\"time-picker\"\n      options={options}\n      placeholder={selectProps.placeholder ?? 'Time'}\n      {...selectProps}\n    />\n  );\n};\n"
    },
    {
      "path": "src/components/timepicker/Timepicker.types.ts",
      "type": "registry:ui",
      "target": "components/ui/wideset/timepicker/Timepicker.types.ts",
      "content": "import type { SelectProps } from '../select/Select.types';\n\n/** A selection control for times within a configured interval. */\nexport type TimePickerProps = {\n  /** Earliest time option in 24-hour `HH:mm` format. Defaults to `00:00`. */\n  min?: string;\n  /** Latest time option in 24-hour `HH:mm` format. Defaults to `23:59`. */\n  max?: string;\n  /** Minutes between consecutive time options. Defaults to `15`. */\n  intervalInMinutes?: number;\n  /** Display format for the time labels. Defaults to `24h`. */\n  format?: '12h' | '24h';\n  /** For `from`, excludes the last time option; for `to`, excludes the first. Omit to include all options. */\n  mode?: 'from' | 'to';\n} & Omit<SelectProps, 'options'>;\n"
    }
  ],
  "meta": {
    "version": "1.0.0",
    "commit": "8bb3627"
  }
}
