{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "pickup-dropoff-editor",
  "title": "Pickup and Drop-off Editor",
  "type": "registry:block",
  "files": [
    {
      "path": "packages/registry-native/blocks/pickup-dropoff-editor/PickupDropoffEditor.tsx",
      "content": "import { useRef, useState, type ComponentRef, type ReactNode } from 'react'\nimport { View, type ViewProps } from 'react-native'\nimport { ArrowUpDown, CircleDot, MapPin } from 'lucide-react-native'\nimport { Button } from '@/components/ui/button'\nimport { FormField } from '@/components/ui/form-field'\nimport { Icon } from '@/components/ui/icon'\nimport { Input } from '@/components/ui/input'\nimport { SegmentedControl, SegmentedControlItem } from '@/components/ui/segmented-control'\nimport { Text } from '@/components/ui/text'\nimport { cn } from '@/lib/utils'\n\nexport interface PickupDropoffValue {\n  pickup: string\n  destination: string\n}\n\ntype Endpoint = keyof PickupDropoffValue\n\nconst defaultLabels = {\n  pickup: 'Pickup',\n  destination: 'Destination',\n  swap: 'Swap locations',\n  confirm: 'Use these locations',\n  confirming: 'Saving locations…',\n  savedPlaces: 'Saved places',\n  applySavedPlaceTo: 'Fill a saved place into',\n  pickupRequired: 'Enter a pickup address.',\n  destinationRequired: 'Enter a destination.',\n  duplicateDestination: 'Choose a different destination.',\n}\n\nexport interface PickupDropoffEditorProps extends Omit<ViewProps, 'children'> {\n  className?: string\n  value: PickupDropoffValue\n  onValueChange: (value: PickupDropoffValue) => void\n  /** Receives trimmed addresses once both are present and distinct. */\n  onSubmit: (value: PickupDropoffValue) => void\n  /** Caller-composed saved places. Apply an address to the currently targeted field. */\n  savedPlaces?: (applyPlace: (address: string) => void, target: Endpoint, disabled: boolean) => ReactNode\n  loading?: boolean\n  disabled?: boolean\n  labels?: Partial<typeof defaultLabels>\n}\n\nexport function PickupDropoffEditor({\n  value,\n  onValueChange,\n  onSubmit,\n  savedPlaces,\n  loading = false,\n  disabled = false,\n  labels,\n  className,\n  ...props\n}: PickupDropoffEditorProps) {\n  const copy = { ...defaultLabels, ...labels }\n  const pickupInput = useRef<ComponentRef<typeof Input>>(null)\n  const destinationInput = useRef<ComponentRef<typeof Input>>(null)\n  const [target, setTarget] = useState<Endpoint>('destination')\n  const [errors, setErrors] = useState<Partial<PickupDropoffValue>>({})\n  const blocked = disabled || loading\n  const confirmLabel = loading ? copy.confirming : copy.confirm\n\n  function change(field: Endpoint, address: string) {\n    if (blocked) return\n    onValueChange({ ...value, [field]: address })\n    setErrors({})\n  }\n\n  function submit() {\n    if (blocked) return\n    const pickup = value.pickup.trim()\n    const destination = value.destination.trim()\n    if (!pickup || !destination || pickup.toLocaleLowerCase() === destination.toLocaleLowerCase()) {\n      const firstError = !pickup ? 'pickup' : 'destination'\n      setErrors({\n        pickup: pickup ? undefined : copy.pickupRequired,\n        destination: !destination ? copy.destinationRequired : pickup ? copy.duplicateDestination : undefined,\n      })\n      setTarget(firstError)\n      if (firstError === 'pickup') pickupInput.current?.focus()\n      else destinationInput.current?.focus()\n      return\n    }\n    setErrors({})\n    onSubmit({ pickup, destination })\n  }\n\n  const places = savedPlaces?.(\n    (address) => {\n      if (blocked || !address.trim()) return\n      change(target, address.trim())\n      if (target === 'pickup') pickupInput.current?.blur()\n      else destinationInput.current?.blur()\n    },\n    target,\n    blocked,\n  )\n\n  return (\n    <View {...props} className={cn('gap-[20px]', className)}>\n      <View className=\"gap-[12px] rounded-lg bg-muted p-[16px]\">\n        <FormField label={copy.pickup} error={errors.pickup} required>\n          {(field) => (\n            <Input\n              {...field}\n              ref={pickupInput}\n              value={value.pickup}\n              editable={!blocked}\n              onChangeText={(address) => change('pickup', address)}\n              onFocus={() => setTarget('pickup')}\n              onSubmitEditing={() => destinationInput.current?.focus()}\n              returnKeyType=\"next\"\n              submitBehavior=\"submit\"\n              prefixIcon={<Icon icon={CircleDot} size={18} className=\"text-muted-foreground\" />}\n            />\n          )}\n        </FormField>\n        <FormField label={copy.destination} error={errors.destination} required>\n          {(field) => (\n            <Input\n              {...field}\n              ref={destinationInput}\n              value={value.destination}\n              editable={!blocked}\n              onChangeText={(address) => change('destination', address)}\n              onFocus={() => setTarget('destination')}\n              onSubmitEditing={submit}\n              returnKeyType=\"done\"\n              prefixIcon={<Icon icon={MapPin} size={18} className=\"text-muted-foreground\" />}\n            />\n          )}\n        </FormField>\n        <Button\n          size=\"sm\"\n          variant=\"outline\"\n          accessibilityLabel={copy.swap}\n          disabled={blocked || value.pickup === value.destination}\n          onPress={() => {\n            if (blocked || value.pickup === value.destination) return\n            onValueChange({ pickup: value.destination, destination: value.pickup })\n            setErrors({})\n          }}\n        >\n          <Icon icon={ArrowUpDown} size={17} />\n          {copy.swap}\n        </Button>\n      </View>\n\n      {places ? (\n        <View className=\"gap-[8px]\">\n          <Text className=\"font-semibold\">{copy.savedPlaces}</Text>\n          <Text size=\"sm\" variant=\"muted\">\n            {copy.applySavedPlaceTo}\n          </Text>\n          <SegmentedControl\n            accessibilityLabel={copy.applySavedPlaceTo}\n            value={target}\n            disabled={blocked}\n            onValueChange={(next) => {\n              if (next === 'pickup' || next === 'destination') setTarget(next)\n            }}\n          >\n            <SegmentedControlItem value=\"pickup\">{copy.pickup}</SegmentedControlItem>\n            <SegmentedControlItem value=\"destination\">{copy.destination}</SegmentedControlItem>\n          </SegmentedControl>\n          {places}\n        </View>\n      ) : null}\n\n      <Button accessibilityLabel={confirmLabel} disabled={disabled} loading={loading} onPress={submit}>\n        {confirmLabel}\n      </Button>\n    </View>\n  )\n}\n",
      "type": "registry:block",
      "target": "~/components/blocks/pickup-dropoff-editor/PickupDropoffEditor.tsx"
    },
    {
      "path": "packages/registry-native/blocks/pickup-dropoff-editor/index.ts",
      "content": "export { PickupDropoffEditor, type PickupDropoffEditorProps, type PickupDropoffValue } from './PickupDropoffEditor'\n",
      "type": "registry:block",
      "target": "~/components/blocks/pickup-dropoff-editor/index.ts"
    }
  ],
  "dependencies": [
    "lucide-react-native"
  ],
  "devDependencies": [],
  "registryDependencies": [
    "https://native.uipkge.dev/r/native/button.json",
    "https://native.uipkge.dev/r/native/form-field.json",
    "https://native.uipkge.dev/r/native/icon.json",
    "https://native.uipkge.dev/r/native/input.json",
    "https://native.uipkge.dev/r/native/segmented-control.json",
    "https://native.uipkge.dev/r/native/text.json",
    "https://native.uipkge.dev/r/native/utils.json"
  ],
  "description": "A controlled pickup and destination form with address validation, swapping, and caller-owned saved places.",
  "categories": [
    "transport",
    "forms"
  ]
}